-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Module declaration conflicts? #11801
Comments
Can you please paste the file contents into the issue? It's easier than downloading and unzipping the archive. If you define a command that overrides a builtin, save the builtin as an alias with a different name before the definition, e.g., |
The goal is not to replace merge.
I don't see how but sure: config.nuuse padawan.nu
use jedi.nu * jedi.nuexport def main [] {
print (help main)
}
export def "jedi fight" [] {
{laser:"blue"} | merge {HP: 100}
}
export def "jedi health" [] {
$in | get HP
} padawan.nuuse jedi.nu ["jedi health"]
export def main [] {
print (help main)
}
export def merge [base, a,b] {
print $"($base)($a)($b)"
} |
So that anyone reading through the issue can immediately see what the problem is without downloading any files. This is definitely a parser bug. After |
It also doesn't look like a cyclic import. We have a parser guard against cyclic import, and this one doesn't cyclically import anything. But I might actually have a clue what's happening. When parsing So technically it works as intended, but for sure it's very confusing. I think modules should be more self-contained and not inherit too much from the parent scope because it can lead to weird situations like this. |
Describe the bug
This is a "bug" I've been experiencing for quite some time, after helping someone over discord on a similar matter I decided to try and reproduce it in the smallest way possible and this actually quickly revealed the issue which might not be a bug but something the compiler/LSP could probably catch early on: cyclic imports
How to reproduce
Extract the following archive, cd to the folder and run
nu --config config.nu
reproduction_module_conflicts.zip
You will get this error:
The
merge
declared inpadawan.nu
shadows the builtin one for some reason (I'm guessing it has something to do with cyclic imports)Expected behavior
Not sure to be honnest, I'm using a simple technique to overcome that: include the namespace in the def declaration, so instead of
export def merge [] {}
I doexport def "padawan merge" [] {}
, this works and I personally don't mind, I use a few "private" modules so I'm bound to having some level of cyclism.Screenshots
No response
Configuration
Additional context
No response
The text was updated successfully, but these errors were encountered: