xai-org/x-algorithm · error · SemanticCheckFailure

There is no type context

Error message

There is no type context

What it means

getTypeContext returns the innermost scope as the type context and throws when the scope list is empty. Type lookups (aliases, thrift types) are impossible without an active scope.

Source

Thrown at botmaker/src/java/com/twitter/botmaker/compiler/CompilerContext.java:284

  void defineVariable(
      String variableName,
      ASTNode astNode) throws SemanticCheckFailure {
    defineVariable(variableName, astNode.getReturnType(), astNode);
  }

  Variable getVariable(String variableText) throws SemanticCheckFailure {
    for (CompilerScope scope : scopeList) {
      if (scope.isVariableDefined(variableText)) {
        Parameter parameter = scope.getVariable(variableText);
        return new Variable(variableText, parameter);
      }
    }
    throw new SemanticCheckFailure(String.format("variable %s not defined", variableText));
  }

  TypeContext getTypeContext() throws SemanticCheckFailure {
    if (scopeList.isEmpty()) {
      throw new SemanticCheckFailure("There is no type context");
    }

    return scopeList.getFirst();
  }

  void defineType(ThriftType thriftType, String alias) throws SemanticCheckFailure {
    if (scopeList.size() <= 1) {
      throw new SemanticCheckFailure(
          String.format("type cannot defined in root scope: %s", alias));
    }

    CompilerScope scope = currentScope();
    scope.defineType(thriftType, alias);
  }

  void defineType(ThriftStructType scroogeType, String alias) throws SemanticCheckFailure {
    if (scopeList.size() <= 1) {
      throw new SemanticCheckFailure(

View on GitHub (pinned to 24c60942c5)

Solutions

  1. Resolve types inside the compile-time scope (within createASTNodeTree/compile)
  2. Push a scope with addScope() before type resolution
  3. Move type alias definitions/imports into a scoped construct so lookups happen with an active scope
Defensive patterns

Strategy: try-catch

Try / catch

catch (SemanticCheckFailure e) { /* internal: ensure type resolution occurs within compile() with a pushed scope */ }

Prevention

When it happens

Trigger: Calling type resolution helpers (type, paramTp) before any scope is pushed, e.g. during a custom compilation phase that runs outside compile() or after scopes were cleared.

Common situations: Custom CompilerUnit hooks resolving types at registration time instead of compile time; misuse of the internal API; error-path scope unwinding.

Related errors


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