xai-org/x-algorithm · error · SemanticCheckFailure

TestRun function expects 1 arguments but %d received

Error message

TestRun function expects 1 arguments but %d received

What it means

TestRun(name) takes exactly one argument identifying the test run block. The compiler checks childCount != 2 (function token + one arg) and rejects everything else.

Source

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

            String.format("MockPassAll function expects 1 arguments but %d received",
                root.getChildCount() - 1)
        );
      }
    } catch (Exception e) {
      throw new SemanticCheckFailure(e);
    }

    return Constant.UNIT;
  }

  private ASTNode toTestRun(
      CompilerContext context,
      String exprText,
      Tree root) throws SemanticCheckFailure {
    try {

      if (root.getChildCount() != 2) {
        throw new SemanticCheckFailure(
            String.format("TestRun function expects 1 arguments but %d received",
                root.getChildCount() - 1)
        );
      }

      context.addScope();
      context.addTestScope();
      Tree target = root.getChild(1);
      ASTNode node = createASTNodeTree(context, target);
      ASTNode testRun = new TestRun("TestRun", ImmutableList.of(node));

      context.removeTestScope();
      context.removeScope();
      return testRun;
    } catch (Exception e) {
      throw new SemanticCheckFailure(e);
    }
  }

View on GitHub (pinned to 24c60942c5)

Solutions

  1. Pass exactly one identifier/string argument to TestRun
  2. Fix the template that generates the TestRun invocation

Example fix

// before
TestRun()
// after
TestRun("baseline")
Defensive patterns

Strategy: validation

Validate before calling

if (testRunArgs != 1) throw new IllegalArgumentException("TestRun takes exactly 1 arg");

Try / catch

catch (SemanticCheckFailure e) { if (e.getMessage().contains("TestRun")) fixArity(); else throw e; }

Prevention

When it happens

Trigger: `TestRun()` with no argument or `TestRun("a", "b")` with more than one.

Common situations: Templated/generated test harnesses that conditionally omit the run name or append extra config arguments not supported by this construct.

Related errors


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