fix(parser): namespace pollution of constants by use module.nu#15518
fix(parser): namespace pollution of constants by use module.nu#15518fdncred merged 2 commits intonushell:mainfrom
use module.nu#15518Conversation
|
@NotTheDr01ds Please review this with care. |
|
Thanks, can you add a test that the scope is only filled by those marked as |
Sure, just figured out where to make that happen. Oh, I should be more clear. The bug is that even exported constants shouldn't be available by calling |
|
Another interesting issue:
export module "mod name" {
export const var_name = "const value"
}
|
|
Looks good. Does that issue appear also without #14920 applied? I.e., is it related to your changes, or is it just a bug in the const/module implementation? |
|
Basically space is not allowed in variable identifiers, but allowed in module names. So the problem arises when trying to reference a module as a variable. TBH, I'm not a fan of such semantics, making lsp tasks more difficult, and the memory management is not well optimized. |
|
The space comes from space being used as a submodule separator. We were thinking changing it to the more traditional |
|
Can we make |
By I thought if we choose to go for the |
I mean the module record variable.
Sorry if I'm missing something obvious, but why not? |
Could be my misunderstanding. I thought Currently if we execute |
|
The :: change is a substantial language change that still needs some design that's better done elsewhere, but yeah, I think it would allow us to move away from the module records. |
|
Seems like the discussion has gone a little bit off topic but as it relates to this PR, I think we're ready to land this. Thanks! |

A bug introduced by #14920
When
use module.nuis 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.fooaccess) are injected.User-Facing Changes
Tests + Formatting
todo!adjusted
After Submitting