{"record":{"id":"434eebe869114191","repo":"xai-org/x-algorithm","slug":"cannot-assign-symbol-type-to-variable","errorCode":null,"errorMessage":"Cannot assign SYMBOL type to variable","messagePattern":"Cannot assign SYMBOL type to variable","errorType":"validation","errorClass":"SemanticCheckFailure","httpStatus":null,"severity":"error","filePath":"botmaker/src/java/com/twitter/botmaker/compiler/Compiler.java","lineNumber":1139,"sourceCode":"      variables.add(assignment);\n      context.defineVariable(assignment.getFirst(), assignment.getSecond());\n    }\n\n    final ASTNode bodyASTNode = createASTNodeTree(context, root.getChild(variableCount));\n    context.removeScope();\n\n    final ASTNode result = With.of(root.getText(), variables, bodyASTNode);\n    return result;\n  }\n\n  private Pair<String, ASTNode> toAssignment(CompilerContext context, Tree root)\n      throws ParseFailure, SemanticCheckFailure {\n    final String variableName = getVariableName(root.getChild(0));\n    final Tree variableRhsNode = root.getChild(1);\n    final ASTNode varExprASTNode = createASTNodeTree(context, variableRhsNode);\n\n    if (varExprASTNode.getReturnType() == Type.SYMBOL) {\n      throw new SemanticCheckFailure(\"Cannot assign SYMBOL type to variable\");\n    }\n\n    return Pair.of(variableName, varExprASTNode);\n  }\n\n  private ASTNode toDerivedFeatureFunction(\n      CompilerContext context, String funcName, int lineNo, List<ASTNode> children\n  ) throws ParseFailure, SemanticCheckFailure {\n    if (context.containsMacro(funcName)) {\n      throw new SemanticCheckFailure(String.format(\n          \"Recursive invocation of derived feature function %s is prohibited\", funcName));\n    }\n\n    Optional<DerivedFeature> dfOpt = context.getDerivedFeature(funcName);\n    if (!dfOpt.isPresent()) {\n      throw new SemanticCheckFailure(String.format(\n          \"%s is not a derived feature function\", funcName));\n    }","sourceCodeStart":1121,"sourceCodeEnd":1157,"githubUrl":"https://github.com/xai-org/x-algorithm/blob/24c60942c5c5fdad3a6addffb4c6e6d2f228f04f/botmaker/src/java/com/twitter/botmaker/compiler/Compiler.java#L1121-L1157","documentation":"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.","triggerScenarios":"`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.","commonSituations":"Misspelled feature/variable names on the right-hand side of an assignment, or referencing a variable before it is defined in the scope.","solutions":["Check the RHS identifier spelling and define the referenced variable/feature first","Use an actual feature lookup or literal instead of a bare symbol on the RHS"],"exampleFix":"// before\nx = undefinedFeatureName\n// after\nx = GetFeature(\"undefinedFeatureName\")","handlingStrategy":"validation","validationCode":"if (rhsNodeLooksLikeBareSymbol(rhsText) && !isDeclared(rhsText)) throw new IllegalArgumentException(\"RHS resolves to SYMBOL: \" + rhsText);","typeGuard":null,"tryCatchPattern":"catch (SemanticCheckFailure e) { if (e.getMessage().contains(\"SYMBOL\")) reportUndeclaredRhsIdentifier(e); else throw e; }","preventionTips":["Declare variables before use","Use feature lookup functions instead of bare identifiers on assignment RHS"],"tags":["botmaker","variable-assignment","symbol-type"],"backgroundTag":"invalid-variable-type","analyzedSha":"24c60942c5c5fdad3a6addffb4c6e6d2f228f04f","analyzedAt":"2026-08-28T11:40:14.686Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}