{"record":{"id":"1ad555827b7c72d9","repo":"xai-org/x-algorithm","slug":"parameter-d-of-s-should-be-s-received-s-inst","errorCode":null,"errorMessage":"Parameter #%d of %s should be %s, received %s instead","messagePattern":"Parameter #(.+?) of (.+?) should be (.+?), received (.+?) instead","errorType":"validation","errorClass":"SemanticCheckFailure","httpStatus":null,"severity":"error","filePath":"botmaker/src/java/com/twitter/botmaker/compiler/Compiler.java","lineNumber":1193,"sourceCode":"      ImmutableList.Builder<ASTNode> builder = ImmutableList.builder();\n      builder.addAll(children);\n      for (int i = children.size(); i < params.size(); i++) {\n        Tree tree = params.get(i).getThird().get();\n        ASTNode child = createASTNodeTree(context, tree);\n        builder.add(child);\n      }\n      args = builder.build();\n    }\n\n    List<Pair<String, ASTNode>> variables = Lists.newArrayListWithCapacity(params.size());\n    context.addScope();\n    for (int i = 0; i < params.size(); i++) {\n      String paramName = params.get(i).getSecond();\n      Type paramTp =\n          TypeCompiler.getType(params.get(i).getFirst(), context.getTypeContext());\n      ASTNode arg = args.get(i);\n      if (Type.isDivergentTo(paramTp, arg.getReturnType())) {\n        throw new SemanticCheckFailure(String.format(\n            \"Parameter #%d of %s should be %s, received %s instead\",\n            i + 1, funcName, paramTp, arg.getReturnType()));\n      }\n      variables.add(Pair.of(paramName, arg));\n\n      context.defineVariable(paramName, paramTp, arg);\n    }\n\n    context.addMacro(funcName);\n    ASTNode bodyASTNode = context.getCachedDFBody(derivedFeature);\n    context.removeMacro(funcName);\n    context.removeScope();\n\n    return DerivedFeatureCall.of(derivedFeature, isLogged, lineNo, variables, bodyASTNode);\n  }\n\n  private ASTNode toMock(\n      CompilerContext context,","sourceCodeStart":1175,"sourceCodeEnd":1211,"githubUrl":"https://github.com/xai-org/x-algorithm/blob/24c60942c5c5fdad3a6addffb4c6e6d2f228f04f/botmaker/src/java/com/twitter/botmaker/compiler/Compiler.java#L1175-L1211","documentation":"Each argument to a derived feature call is checked against the declared parameter type; if the argument's return type diverges from the expected type (no implicit coercion), the call is rejected with the 1-based parameter position.","triggerScenarios":"Passing a Double where the parameter is Long, a String where a struct is expected, or null/OBJECT-typed values for a typed parameter.","commonSituations":"Numeric literals defaulting to the wrong type (e.g. 1.0 vs 1L), passing an untyped feature value (OBJECT) into a typed parameter, or signature type changes not propagated to call sites.","solutions":["Convert the argument to the declared type (ToLong, ToDouble, ToString, etc.)","Fix the literal form (1L for Long, 1.0 for Double)","Align the call site with the parameter's declared type after signature changes"],"exampleFix":"// before\nderived feature score(x: Long) = ...\nvalue = score(1.5)\n// after\nvalue = score(1L)","handlingStrategy":"type-guard","validationCode":"for (i in params) if (Type.isDivergentTo(paramType[i], argType[i])) throw new IllegalArgumentException(\"Arg \" + i + \" type mismatch\");","typeGuard":"static boolean argsConform(List<Type> params, List<Type> args) { for (int i=0;i<params.size();i++) if (Type.isDivergentTo(params.get(i), args.get(i))) return false; return true; }","tryCatchPattern":"catch (SemanticCheckFailure e) { if (e.getMessage().contains(\"should be\")) surfaceExpectedVsActual(e); else throw e; }","preventionTips":["Use explicit numeric literal suffixes (1L, 1.0)","Insert explicit coercions (ToLong/ToDouble) at call boundaries"],"tags":["botmaker","derived-feature","type-mismatch","arguments"],"backgroundTag":"argument-type-mismatch","analyzedSha":"24c60942c5c5fdad3a6addffb4c6e6d2f228f04f","analyzedAt":"2026-08-28T11:40:14.686Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}