{"record":{"id":"4930a630d485c57f","repo":"xai-org/x-algorithm","slug":"col-d-type-s-received-d-parameters-d-expecte","errorCode":null,"errorMessage":"col %d: Type %s received %d parameters, %d expected","messagePattern":"col (.+?): Type (.+?) received (.+?) parameters, (.+?) expected","errorType":"exception","errorClass":"ParseFailure","httpStatus":null,"severity":"error","filePath":"botmaker/src/java/com/twitter/botmaker/compiler/types/TypeCompiler.java","lineNumber":78,"sourceCode":"      builder.append('.').append(tree.getChild(index).getText());\n    }\n    return builder.toString();\n  }\n\n  private static Type getCompositeType(\n      Tree tree,\n      TypeContext context\n  ) throws ParseFailure, SemanticCheckFailure {\n    String tname = tree.getChild(0).getText();\n    Optional<Pair<Class<?>, Integer>> infoOpt = Type.getCompositeClassInfoFromName(tname);\n    if (!infoOpt.isPresent()) {\n      throw new ParseFailure(String.format(\n          \"col %d: Unrecognized type: %s\",\n          tree.getCharPositionInLine() + 1, tname));\n    }\n    Pair<Class<?>, Integer> info = infoOpt.get();\n    if (info.getSecond() != tree.getChildCount() - 1 && info.getSecond() != Type.ANY_NUM_PARAMS) {\n      throw new ParseFailure(String.format(\n          \"col %d: Type %s received %d parameters, %d expected\",\n          tree.getCharPositionInLine() + 1, tname, tree.getChildCount() - 1, info.getSecond()));\n    }\n    ImmutableList.Builder<Type> paramTypesBuilder = ImmutableList.builder();\n    for (int i = 1; i < tree.getChildCount(); i++) {\n      paramTypesBuilder.add(getType(tree.getChild(i), context));\n    }\n    return Type.of(info.getFirst(), paramTypesBuilder.build());\n  }\n\n  public static Optional<Type> getPrimitiveType(String name) {\n    return Type.getPrimitiveTypeFromName(name);\n  }\n\n  public static Type getTypeFromClassName(String className) throws SemanticCheckFailure {\n\n    Class<?> clazz;\n    try {","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/xai-org/x-algorithm/blob/24c60942c5c5fdad3a6addffb4c6e6d2f228f04f/botmaker/src/java/com/twitter/botmaker/compiler/types/TypeCompiler.java#L60-L96","documentation":"After resolving a composite head, getCompositeType checks the number of type parameters (child count) against the expected arity from getCompositeClassInfoFromName. A mismatch throws ParseFailure with received vs expected counts.","triggerScenarios":"Writing e.g. Map[INT] (1 param, expects 2), List[INT, STRING] (2 params, expects 1), or Pair with 3 parameters in a rule's type expression.","commonSituations":"Copy-pasting generic signatures from Java/Scala without adjusting arity; assuming Map takes one key-value param; editor auto-complete inserting extra brackets.","solutions":["Supply exactly the expected parameter count: List/Set take 1, Map/Pair take 2","Check the message's 'received N, expected M' and fix the type expression","Use nested composites (Map[INT, List[STRING]]) instead of flattening"],"exampleFix":"// before\nm: Map[INT]\n// after\nm: Map[INT, STRING]","handlingStrategy":"validation","validationCode":"int expected = Type.getCompositeClassInfoFromName(head).get().getSecond();\nif (expected != Type.ANY_NUM_PARAMS && given != expected) rejectRule();","typeGuard":null,"tryCatchPattern":"catch ParseFailure; report received/expected counts to the author","preventionTips":["Remember arity: List/Set=1, Map/Pair=2","Editor templates for common generic types"],"tags":["parser","type-system","arity"],"backgroundTag":"wrong-number-of-type-arguments","analyzedSha":"24c60942c5c5fdad3a6addffb4c6e6d2f228f04f","analyzedAt":"2026-08-28T11:40:14.686Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}