Maybe bug regarding overriding built in commands in a shared module space
Question
Let say i have two modules
# modules/moduleA.nu
export def hello [--period: duration] { sleep $period; echo "hello from moduleB" }
# modules/moduleB.nu
use moduleA.nu *
export def sleep [] { echo "hello from moduleA" }
And a global config.nu file
# config.nu
const nushellDir = ($nu.config-path | path parse).parent
const modules = ([$nushellDir, modules] | path join)
use $modules *
This results in a similar error:
× Extra positional argument.
╭─[modules/moduleA.nu:1]
1 │ sleep $period
· ───┬───
· ╰── extra positional argument
Apparently all modules are loaded in the same space, as some sort of lookbehind occurs for modules and it overrides built-ins with custom commands.
Am I doing something incorrectly here? What I initially assumed is that if I import one module into another the target of the import should not affect the logic of the imported module.
[!NOTE] I'm quite unexperienced with nushell behavior as a programming language so sorry if all of this is nonsense
Additional context and details
- OS: Windows
- Nushell Version: 0.102.0
Gotta admit that I am not fully up to speed on the name resolution behavior in modules.
But by just looking at your code, I am not sure if the sleep is shadowed by the use moduleA.nu * in moduleB.nu or by the glob import in your config.nu (so that moduleA's sleep already shadowed the builtin, when moduleB got to parsing.)