xai-org/x-algorithm · error · SemanticCheckFailure

Cannot assign SYMBOL type to variable

Error message

Cannot assign SYMBOL type to variable

What it means

Variables in Botmaker cannot hold the SYMBOL type (an unresolved identifier/reference type). Assigning a SYMBOL-typed expression to a named variable would propagate an unusable, unresolved value.

Source

Thrown at botmaker/src/java/com/twitter/botmaker/compiler/Compiler.java:1139

      variables.add(assignment);
      context.defineVariable(assignment.getFirst(), assignment.getSecond());
    }

    final ASTNode bodyASTNode = createASTNodeTree(context, root.getChild(variableCount));
    context.removeScope();

    final ASTNode result = With.of(root.getText(), variables, bodyASTNode);
    return result;
  }

  private Pair<String, ASTNode> toAssignment(CompilerContext context, Tree root)
      throws ParseFailure, SemanticCheckFailure {
    final String variableName = getVariableName(root.getChild(0));
    final Tree variableRhsNode = root.getChild(1);
    final ASTNode varExprASTNode = createASTNodeTree(context, variableRhsNode);

    if (varExprASTNode.getReturnType() == Type.SYMBOL) {
      throw new SemanticCheckFailure("Cannot assign SYMBOL type to variable");
    }

    return Pair.of(variableName, varExprASTNode);
  }

  private ASTNode toDerivedFeatureFunction(
      CompilerContext context, String funcName, int lineNo, List<ASTNode> children
  ) throws ParseFailure, SemanticCheckFailure {
    if (context.containsMacro(funcName)) {
      throw new SemanticCheckFailure(String.format(
          "Recursive invocation of derived feature function %s is prohibited", funcName));
    }

    Optional<DerivedFeature> dfOpt = context.getDerivedFeature(funcName);
    if (!dfOpt.isPresent()) {
      throw new SemanticCheckFailure(String.format(
          "%s is not a derived feature function", funcName));
    }

View on GitHub (pinned to 24c60942c5)

Solutions

  1. Check the RHS identifier spelling and define the referenced variable/feature first
  2. Use an actual feature lookup or literal instead of a bare symbol on the RHS

Example fix

// before
x = undefinedFeatureName
// after
x = GetFeature("undefinedFeatureName")
Defensive patterns

Strategy: validation

Validate before calling

if (rhsNodeLooksLikeBareSymbol(rhsText) && !isDeclared(rhsText)) throw new IllegalArgumentException("RHS resolves to SYMBOL: " + rhsText);

Try / catch

catch (SemanticCheckFailure e) { if (e.getMessage().contains("SYMBOL")) reportUndeclaredRhsIdentifier(e); else throw e; }

Prevention

When it happens

Trigger: `var x = someUndefinedIdentifier` where the RHS compiles to Type.SYMBOL, e.g. referencing an undeclared variable or feature name that resolves as a bare symbol.

Common situations: Misspelled feature/variable names on the right-hand side of an assignment, or referencing a variable before it is defined in the scope.

Related errors


AI-assisted analysis of xai-org/x-algorithm@24c60942c5 (2026-08-28). Data as JSON: /api/errors/434eebe869114191. Report an issue: GitHub.