refactor(parser): use var_id for most constants in ResolvedImportPattern#14920
Merged
kubouch merged 1 commit intonushell:mainfrom Jan 26, 2025
Merged
refactor(parser): use var_id for most constants in ResolvedImportPattern#14920kubouch merged 1 commit intonushell:mainfrom
ResolvedImportPattern#14920kubouch merged 1 commit intonushell:mainfrom
Conversation
ResolvedImportPatternResolvedImportPattern
Contributor
|
I think this is fine. Maybe VarId was changed to Value because it wasn't needed anymore? Anyway, I don't see any problem with this PR. Thanks! |
fdncred
pushed a commit
that referenced
this pull request
May 1, 2025
) A bug introduced by #14920 When `use module.nu` is called, all exported constants defined in it are added to the scope. # Description On the branch of empty arguments, the constant var_id vector should be empty, only constant_values (for `$module.foo` access) are injected. # User-Facing Changes # Tests + Formatting ~todo!~ adjusted # After Submitting
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.
Description
This PR replaces most of the constants in
ResolvedImportPatternfrom values to VarIds, this has benefits of:goto defon a const imported by theusecommand, this allows it to find the original definition, instead of where theusecommand is.Note that the logic is different here for nested submodules, not all values are flattened and propagated to the outmost record variable, but I didn't find any differences in real world usage.
I noticed that it was changed from
VarIdtoValuein #10049.Maybe @kubouch can find some edge cases where this PR fails to work as expected.
In my view, the record constants for
ResolvedImportPatternshould even reduced to single entry, if not able to get rid of.User-Facing Changes
Tests + Formatting
After Submitting