bazelbuild/bazel · error · EvalException
isinstance() is not yet supported
Error message
isinstance() is not yet supported
What it means
The parser of this Starlark dialect can produce an ISINSTANCE expression node (isinstance(x, T)), but the evaluator does not implement it: evaluating such a node sets the error location and immediately throws EvalException 'isinstance() is not yet supported'. So even though the syntax parses, it can never run in this interpreter version.
Source
Thrown at src/main/java/net/starlark/java/eval/Eval.java:596
// expressions; see b/153764542.
switch (expr.kind()) {
case BINARY_OPERATOR:
return evalBinaryOperator(fr, (BinaryOperatorExpression) expr);
case COMPREHENSION:
return evalComprehension(fr, (Comprehension) expr);
case CONDITIONAL:
return evalConditional(fr, (ConditionalExpression) expr);
case DICT_EXPR:
return evalDict(fr, (DictExpression) expr);
case DOT:
return evalDot(fr, (DotExpression) expr);
case CALL:
return evalCall(fr, (CallExpression) expr);
case CAST:
return eval(fr, ((CastExpression) expr).getValue());
case ISINSTANCE:
fr.setErrorLocation(expr.getStartLocation());
throw new EvalException("isinstance() is not yet supported");
case IDENTIFIER:
return evalIdentifier(fr, (Identifier) expr);
case INDEX:
return evalIndex(fr, (IndexExpression) expr);
case INT_LITERAL:
// TODO(adonovan): opt: avoid allocation by saving
// the StarlarkInt in the IntLiteral (a temporary hack
// until we use a compiled representation).
Number n = ((IntLiteral) expr).getValue();
if (n instanceof Integer nInt) {
return StarlarkInt.of(nInt);
} else if (n instanceof Long nLong) {
return StarlarkInt.of(nLong);
} else {
return StarlarkInt.of((BigInteger) n);
}
case FLOAT_LITERAL:
return StarlarkFloat.of(((FloatLiteral) expr).getValue());View on GitHub (pinned to e6e199d060)
Solutions
- Replace isinstance() with a type check that is supported: type(x) == type(y), x == True for booleans, hasattr(x, 'attr') for capability checks, or type(x).name comparisons.
- Restructure to avoid type dispatch (use different methods or fail-fast validation of expected value kinds).
- If isinstance semantics are required, move the check into a native Java builtin.
Example fix
# before
if isinstance(v, string): process(v)
# after
if type(v) == type(""): process(v) Defensive patterns
Strategy: validation
Validate before calling
# Reject isinstance before evaluation (simple textual check for toolchains)
if grep -qnE '\bisinstance\s*\(' script.star; then
echo "isinstance() is not supported by this interpreter; use type(x) == type(y)" >&2
exit 2
fi Type guard
# Starlark replacement helper (in a .bzl file)
def is_string(x):
return type(x) == type("")
def is_list(x):
return type(x) == type([]) Prevention
- Do not port Python isinstance() calls into Starlark; translate them to type() comparisons.
- Lint repositories for 'isinstance(' as part of CI for Starlark files.
- Prefer hasattr() capability checks over type checks for Starlark values.
When it happens
Trigger: Evaluating any script containing isinstance(...) under this interpreter build; code ported from python or from a Starlark dialect (e.g. with the isinstance extension enabled in the parser) run on an evaluator lacking the feature.
Common situations: Porting Python validation code to .bzl/Starlark; enabling parser extensions that accept isinstance syntax; version differences between Starlark dialects (one supports it, another only parses it).
Related errors
- Starlark computation cancelled: too many steps
- This converter doesn't support Starlark reversal.
- Invalid options syntax: %s Note: Negative target patterns ca
- Expected one of %s and %s to be a subclass of the other
- Class %s has an incompatible overload of annotated method %s
AI-assisted analysis of bazelbuild/bazel@e6e199d060 (2026-08-14).
Data as JSON: /api/errors/04fac3b30e1887bd.
Report an issue: GitHub.