Repository navigation
feat: export compiler error types for errors.As classification - #216
Merged
Merged
Conversation
ascandone
self-requested a review
October 9, 2026 13:39
ascandone
previously approved these changes
Oct 9, 2026
NumaryBot
reviewed
Oct 9, 2026
Base automatically changed from
claude/export-interpreter-errors-b67bbd
to
main
October 9, 2026 13:49
Compile flattened its typed errors into plain text, and VarsEncoder.Encode built var-binding failures as strings, so a host could only tell compile and var failures apart by string matching. Return compiler errors as is, give var-binding failures typed errors (MissingVariable, InvalidVariableValue), and alias the compiler's error types and the type checker's error kinds from the root package with the same field-stability contract as the interpreter's. Refs EN-2833
Azorlogh
force-pushed
the
claude/export-compiler-errors
branch
from
October 9, 2026 13:52
1352abf to
f779f19
Compare
ascandone
self-requested a review
October 9, 2026 14:28
ascandone
approved these changes
Oct 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs EN-2833.
Ledger compiles committed scripts during Raft apply and must record compile and var-binding failures as structured audit facts. Today
Compileflattens its typed errors withfmt.Errorf("%v", …), andVarsEncoder.Encodebuilds var failures as plain strings, so a host can only match on text.Changes
Compilereturns the compiler's typed error as is (CompilerErrornow embedserror). Messages are unchanged.VarsEncoder.EncodereturnsMissingVariable{Name}andInvalidVariableValue{Name, Type, Raw, Cause}(UnwrapyieldsCause). Messages are unchanged.numscript.goaliases them with aCompilerprefix (the interpreter already exportsTypeError,CannotCastToString,ExperimentalFeature,InvalidFeature), grouped as:CompilerTypeError,CompilerInvalidUncappedSource,CompilerDuplicateRemaining,CompilerInvalidMetaPosition,CompilerCannotCastToString,CompilerCannotStoreScopedAccountInMeta,CompilerExperimentalFeature,CompilerInvalidFeature;CompilerFeatureNotImplemented(only scaling today);CompilerUnboundVar(the type checker rejects unbound variables first),CompilerInvalidScopedAccountPosition,CompilerUnsupportedNode;CompilerMissingVariable,CompilerInvalidVariableValue;CompilerErrorinterface.CompilerTypeError.Kindcomes from the type checker, so its kinds are exported too:TypecheckErrorKind,TypecheckTypeMismatch,TypecheckUnboundVariable,TypecheckInvalidType,TypecheckBadArity,TypecheckUnknownFunction,TypecheckDuplicateVariable.errors_test.go: every non-defect type (and every type-checker kind) is reached throughCompileWithFeatureFlagsorVarsEncoder.Encode, anderrors.Asplus key fields are checked.Not covered: errors from
ir.Typecheck/ir.Assembleafter lowering. They mean the compiler emitted invalid IR (a numscript defect) and stay untyped.