Fix super[i] index-signature access (unreachable + missing isSuperClass)#282
Merged
Conversation
super[i] hit llvm_unreachable: the ElementAccessExpression codegen's super-specific branch only handled a constant string index, with no fallback to route a real (non-constant) index into ClassIndexAccess the way ordinary t[i] access already does. Fixing that exposed the second, originally-suspected bug: ClassIndexAccess never took isSuperClass, so `super[i]`'s thisValue was never repaired via getThisRefOfClass the way ClassMethodAccess/ClassAccessorAccess already do (same class of bug PR #278 fixed for super.<accessor>). Adds a same-file regression test (00class_indexer_super.ts) covering an overridden indexer calling back into the base via super[i]/super[i] = v. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.
Summary
super[i](index-signature access throughsuper) hitllvm_unreachable("not implemented (ElementAccessExpression)")- thesuper-specific branch of element-access codegen only ever handled a constant string index (super["name"]), with no fallback to route a real/computed index intoClassIndexAccessthe way ordinaryt[i]access already does.ClassIndexAccessnever took anisSuperClassparameter at all (a stale// TODO: why isSuperClass is not used here?comment sat right above its declaration), so oncesuper[i]reached it,thisValuewas never repaired viagetThisRefOfClassthe wayClassMethodAccess/ClassAccessorAccessalready do (the same class of bug PR Fix cross-module super-accessor crash and add class coverage #278 fixed forsuper.<accessor>).00class_indexer_super.ts) covering an overridden indexer calling back into the base viasuper[i]/super[i] = value.Test plan
ctest -C Debug -R class-indexer- 4/4 pass (including the new-supertest, compile + jit tiers)ctest -C Debug -j8- 793/793 pass, no regressions