xai-org/x-algorithm · error · SemanticCheckFailure

Function '%s' does not exist

Error message

Function '%s' does not exist

What it means

CompilerScope's own createFunctionASTNode mirrors CompilerBuilder's: it looks up funcName in compilerUnits and throws if absent. Scope-level function application requires the function to be registered in the scope's unit set.

Source

Thrown at botmaker/src/java/com/twitter/botmaker/compiler/CompilerScope.java:119

  }

  void defineType(ThriftStructType thriftStructType, String alias) {
    thriftStructTypes.put(alias, thriftStructType);
    for (CompilerUnit c : CompilerUnit.of(alias, thriftStructType)) {
      compilerUnits.put(c.funcName(), c);
    }
  }

  boolean containsFunction(String name) {
    return compilerUnits.containsKey(name);
  }

  ASTNode createFunctionASTNode(
      CompilerContext context,
      String funcName,
      ImmutableList<ASTNode> children) throws SemanticCheckFailure {
    if (!compilerUnits.containsKey(funcName)) {
      throw new SemanticCheckFailure(String.format("Function '%s' does not exist", funcName));
    }

    CompilerUnit compilerUnit = compilerUnits.get(funcName);
    if (compilerUnit.fingerprint() != Fingerprint.EMPTY) {
      context.trackUsage(compilerUnit);
    }

    return compilerUnit.createASTNode(children);
  }

  @Override
  public Optional<Type> getTypeFromName(String typeName) {
    if (thriftTypes.containsKey(typeName)) {
      return Optional.of(thriftTypes.get(typeName));
    } else if (thriftStructTypes.containsKey(typeName)) {
      return Optional.of(thriftStructTypes.get(typeName));
    } else {
      return surrounding.getTypeFromName(typeName);

View on GitHub (pinned to 24c60942c5)

Solutions

  1. Fix the function name spelling
  2. Register/import the CompilerUnit providing the function into the scope's units
  3. Pre-validate the function name against the available unit set before compiling
Defensive patterns

Strategy: validation

Validate before calling

if (!scopeCompilerUnits.containsKey(funcName)) throw new IllegalArgumentException("Unknown function: " + funcName);

Try / catch

catch (SemanticCheckFailure e) { /* verify function is registered in this scope's units */ }

Prevention

When it happens

Trigger: A function application node compiled through CompilerScope when the function name is not in its compilerUnits map — unknown function, missing import of the defining unit, or a typo.

Common situations: Same as builder-level: renames, missing unit registration, version drift, typos in DSL function names.

Related errors


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