fix(sema): remap imported builtin locations to import loc (#1305)#1850
Open
0takuc0mrade wants to merge 2 commits intohyperledger-solang:mainfrom
Open
fix(sema): remap imported builtin locations to import loc (#1305)#18500takuc0mrade wants to merge 2 commits intohyperledger-solang:mainfrom
0takuc0mrade wants to merge 2 commits intohyperledger-solang:mainfrom
Conversation
…r-solang#1305) Signed-off-by: 0takuc0mrade <junep059@gmail.com>
Signed-off-by: 0takuc0mrade <junep059@gmail.com>
3da2275 to
795921e
Compare
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
Fixes #1305 by preventing diagnostic panics caused by
Loc::Builtinnotes when importing target builtins.Problem
When builtin symbols are imported (for example from
import "polkadot";) and then collide with user-defined symbols (for examplechain_extension), diagnostics may include notes withLoc::Builtin.Diagnostic rendering expects note locations to be file-backed (
Loc::File) and could panic with:internal error: entered unreachable code: note without file positionWhat Changed
replace_builtin_loc(symbol, import_loc)insrc/sema/mod.rs.resolve_import, wrapped imported symbols with this helper beforens.add_symbol()for:pt::Import::Renamept::Import::Plainreplace_builtin_locrewritesLoc::Builtinentries to the import statement location (import_loc) while leaving non-builtin locations unchanged.Behavior Change
Before:
Loc::Builtin.After:
Scope / Safety
resolve_import).Loc::Builtinis remapped; all existingLoc::Filelocations are preserved.Validation