Conversation
…blocks typeof consumer migrations (array/binary/conditional recurse through symbol table set mid-codegen)
Contributor
Benchmark Results (Linux x86-64)
CLI Tool Benchmarks
|
This was referenced Apr 20, 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.
Root-cause fix. The AST type annotator (src/semantic/type-annotator.ts) was populating the typeOf cache for every expression pre-codegen. But arrays/binary/conditional/new/object/map/set/type_assertion expressions recurse into the symbol table (isString, getType) whose answers only exist mid-codegen. Cached pre-codegen → stale wrong answer; downstream consumers reading base/arrayDepth from that cached rich object got misclassified types → native IR type mismatches.
Diagnostic trail: the previous attempt to migrate variable-allocator (PR #578 rollback) failed with
'%N' defined with type 'double' but expected 'ptr'on stage 1 self-compile. Side-effect test showed calling typeOf+discarding worked; using its return broke — proved the returned value was wrong, not a side effect. Instrumentation side-by-side (typeOf vs flat) found 397 divergences: 342 array (number[]vsstring[]), 29 conditional, 26 binary. All caused by annotator caching with empty symbol table.Fix: shrink annotator's cache-set to truly-static types (number/string/template_literal/boolean/null/regex). Everything else resolves live via typeOf's fallback to resolveExpressionTypeRich.
Also in this PR: variable-allocator.ts uses typeOf() at the decl-type site — was rolled back in #578 due to this bug; now safe with the annotator fix. Pattern for future consumer migrations is now sound.
Test plan:
🤖 Generated with Claude Code