xai-org/x-algorithm · error · SemanticCheckFailure
StructTuple expects pairs of name and values, but a %s recei
Error message
StructTuple expects pairs of name and values, but a %s received
What it means
When constructing a StructTuple node, every child must be a ToPair (name, value) mapping a field name to its value. Any other child node type (a bare constant, function call, etc.) is rejected with this error.
Source
Thrown at botmaker/src/java/com/twitter/botmaker/compiler/CompilerUnit.java:276
@Override
public BotMakerDoc botMakerDoc() {
return description;
}
@Override
public Fingerprint fingerprint() {
return Fingerprint.EMPTY;
}
@Override
public ASTNode createASTNode(ImmutableList<ASTNode> children) throws SemanticCheckFailure {
ImmutableList<String> fieldNames = structTupleType.fieldNames;
ASTNode[] fieldValues = new ASTNode[fieldNames.size()];
for (ASTNode child : children) {
if (!(child instanceof ToPair)) {
throw new SemanticCheckFailure(
String.format(
"StructTuple expects pairs of name and values, but a %s received", child)
);
}
String fieldName = ((Constant) child.getChildren().get(0)).getValue().toString();
if (!fieldNames.contains(fieldName)) {
throw new SemanticCheckFailure(
String.format("Field %s does not belong to %s", fieldName, toString())
);
}
fieldValues[fieldNames.indexOf(fieldName)] = (ASTNode) child.getChildren().get(1);
}
return new ToStructTuple(fn, fieldNames, ImmutableList.copyOf(fieldValues)) {
@Override
public Signature getSignature() {
return signature;
}View on GitHub (pinned to 24c60942c5)
Solutions
- Rewrite the struct literal using field=value pairs for every field
- Check the struct's expected fields and provide each as a named pair
- If generating code, emit ToPair nodes for each field
Example fix
// before MyStruct(a, b) // after MyStruct(field1 = a, field2 = b)
Defensive patterns
Strategy: validation
Validate before calling
for (ASTNode c : children) if (!(c instanceof ToPair)) throw new IllegalArgumentException("StructTuple children must be name=value pairs"); Type guard
boolean isFieldPair(ASTNode n) { return n instanceof ToPair; } Try / catch
catch (SemanticCheckFailure e) { /* rewrite struct literal as field=value pairs */ } Prevention
- Always construct struct literals with explicit field names
- Lint generated code for bare children in struct constructors
When it happens
Trigger: Passing non-pair children to a struct-tuple constructor in the DSL, e.g. 'StructType(value1, value2)' instead of 'StructType(field = value1, other = value2)', so a child ASTNode is not an instance of ToPair.
Common situations: Writing struct literals positionally instead of by field name; DSL syntax changes; generated code emitting bare expressions inside struct constructors.
Related errors
- Field %s does not belong to %s
- unrecognized function name:
- class to be imported has to be either a TBase or ThriftStruc
- cannot find class %s
- function passed to Foldl() returns %s but seed value is a %s
AI-assisted analysis of xai-org/x-algorithm@24c60942c5 (2026-08-28).
Data as JSON: /api/errors/2c22c349bb8bdada.
Report an issue: GitHub.