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 debug printing for expect_test in the parser and other places. #1321
Labels
Comments
sezna
added
bug
Something isn't working
needs triage
enhancement
New feature or request
rust
Pull requests that update Rust code
and removed
bug
Something isn't working
needs triage
labels
Mar 27, 2024
This was referenced Apr 6, 2024
@sezna , I would like to work on this issue. |
github-merge-queue bot
pushed a commit
that referenced
this issue
May 17, 2024
_This PR replaces #1364_ 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: 1. Naked namespaces (files without namespace declarations) 2. Package publishing and sharing 3. Explicit item imports 4. Exports and re-exports 5. and the rest of the stuff [here](#493 (comment)) Key changes include: 1. `VecIdent` type introduction: This abstraction over `Vec<Ident>` represents the new namespaces in the AST. Alternate names could be `DotIdent` or `Path`, but those names were already loaded with meaning in our codebase. I'm open to feedback on nomenclature here. 7. `NamespaceId` usage: This replaces our previous flat map-style `Rc<str> -> Res` item tracking. 8. `NamespaceTree`: This tracks the namespace hierarchy separately in low-cost data structure, and allows us to keep our basic `tys` and `terms` maps relatively untouched. 9. Name resolution algorithm update: The algorithm in `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: 1. Katas used a form of shadowing that wasn't tested in our compiler. This PR [adds a test](https://github.com/microsoft/qsharp/pull/1312/files#diff-7a3aa16f18f6d132b9e54a6b6ebd53e6c3b41cea805c8f8db9c456b533a3c96bR2787) for that. 2. Pursuing #1321 could help differentiate user-facing and compiler-engineer-facing string representations of structs, which are increasingly conflated. 3. There's potential for refactoring `ast`, `fir`, and `hir` to use shared generic types, reducing duplicate `Ident`/etc types. 4. Completions functionality remains the same, but it's not yet aware of the ability to partially open namespaces (e.g. `open Microsoft.Quantum`. This will be addressed in future updates. 5. There is a performance regression, but we are performing a full tree-traversal namespace resolution algorithm in a place where we used to just do a constant table lookup. I have optimized this as much as I believe is reasonable for now, bringing the regression down from ~40%, where it was originally, to around 5-10% based on the benchmark run. Also closes #1336 --------- Co-authored-by: Mine Starks <mineyalc@microsoft.com> Co-authored-by: Mine Starks <16928427+minestarks@users.noreply.github.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We currently use
ToString::to_string
(i.e.,Display
) in our expect test tests for the parser (see here). This is problematic, because this trait is typically used for user-facing representations of data structures. We are forced to choose between a pretty user-facing representation, and a more technically accurate debug-style representation for testing for namespace names in #1312 as a result.The text was updated successfully, but these errors were encountered: