-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use hierarchical namespaces in name resolution #1364
Closed
Conversation
This file contains 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
Change in memory usage detected by benchmark. Memory Report for 7ee63da
|
Benchmark for 7ee63daClick to view benchmark
|
Change in memory usage detected by benchmark. Memory Report for 96435a5
|
Benchmark for 96435a5Click to view benchmark
|
Change in memory usage detected by benchmark. Memory Report for bb286cf
|
Benchmark for bb286cfClick to view benchmark
|
Change in memory usage detected by benchmark. Memory Report for f49b284
|
Change in memory usage detected by benchmark. Memory Report for ae43fef
|
Benchmark for ae43fefClick to view benchmark
|
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.
Note: I see the performance degradation in the memory and performance benchmarks, and am looking into that
This PR introduces a feature called hierarchical namespaces, a module-like system that maintains backward compatibility. It is the foundational groundwork that will pave the way for:
Key changes include:
VecIdent
type introduction: This abstraction overVec<Ident>
represents the new namespaces in the AST. Alternate names could beDotIdent
orPath
, but those names were already loaded with meaning in our codebase. I'm open to feedback on nomenclature here.NamespaceId
usage: This replaces our previous flat map-styleRc<str> -> Res
item tracking.NamespaceTree
: This tracks the namespace hierarchy separately in low-cost data structure, and allows us to keep our basictys
andterms
maps relatively untouched.resolve.rs
received a heavy facelift. Not only did I try to simplify the existing code, but I also added the required functionality to check candidate partially-opened or re-opened namespaces.This PR maintains 100% backward compatibility with the existing resolution engine, preserving features like re-opening namespaces, shadowing semantics, merging namespaces via aliases, and absolute-path opens. It also introduces the ability to reference a function in a different namespace if its parent namespace is opened.
Additional notes:
ast
,fir
, andhir
to use shared generic types, reducing duplicateIdent
/etc types.open Microsoft.Quantum
. This will be addressed in future updates.Also closes #1336