xai-org/x-algorithm · error · ParseFailure
col %d: Type %s received %d parameters, %d expected
Error message
col %d: Type %s received %d parameters, %d expected
What it means
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.
Source
Thrown at botmaker/src/java/com/twitter/botmaker/compiler/types/TypeCompiler.java:78
builder.append('.').append(tree.getChild(index).getText());
}
return builder.toString();
}
private static Type getCompositeType(
Tree tree,
TypeContext context
) throws ParseFailure, SemanticCheckFailure {
String tname = tree.getChild(0).getText();
Optional<Pair<Class<?>, Integer>> infoOpt = Type.getCompositeClassInfoFromName(tname);
if (!infoOpt.isPresent()) {
throw new ParseFailure(String.format(
"col %d: Unrecognized type: %s",
tree.getCharPositionInLine() + 1, tname));
}
Pair<Class<?>, Integer> info = infoOpt.get();
if (info.getSecond() != tree.getChildCount() - 1 && info.getSecond() != Type.ANY_NUM_PARAMS) {
throw new ParseFailure(String.format(
"col %d: Type %s received %d parameters, %d expected",
tree.getCharPositionInLine() + 1, tname, tree.getChildCount() - 1, info.getSecond()));
}
ImmutableList.Builder<Type> paramTypesBuilder = ImmutableList.builder();
for (int i = 1; i < tree.getChildCount(); i++) {
paramTypesBuilder.add(getType(tree.getChild(i), context));
}
return Type.of(info.getFirst(), paramTypesBuilder.build());
}
public static Optional<Type> getPrimitiveType(String name) {
return Type.getPrimitiveTypeFromName(name);
}
public static Type getTypeFromClassName(String className) throws SemanticCheckFailure {
Class<?> clazz;
try {View on GitHub (pinned to 24c60942c5)
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
Example fix
// before m: Map[INT] // after m: Map[INT, STRING]
Defensive patterns
Strategy: validation
Validate before calling
int expected = Type.getCompositeClassInfoFromName(head).get().getSecond(); if (expected != Type.ANY_NUM_PARAMS && given != expected) rejectRule();
Try / catch
catch ParseFailure; report received/expected counts to the author
Prevention
- Remember arity: List/Set=1, Map/Pair=2
- Editor templates for common generic types
When it happens
Trigger: 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.
Common situations: Copy-pasting generic signatures from Java/Scala without adjusting arity; assuming Map takes one key-value param; editor auto-complete inserting extra brackets.
Related errors
- col %d: Unrecognized type: %s
- Derived Feature %s has %d parameters, received %d
- Mock function expects either 1 or 3 arguments but %d receive
- MockPass function expects either 1 arguments but %d received
- MockPassAll function expects 1 arguments but %d received
AI-assisted analysis of xai-org/x-algorithm@24c60942c5 (2026-08-28).
Data as JSON: /api/errors/4930a630d485c57f.
Report an issue: GitHub.