Skip to content

Maybe bug regarding overriding built in commands in a shared module space #15315

Open
@DavidTelenko

Description

@DavidTelenko

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    modulesquestionthe issue author asks somethingscoping/name-resolutionHow Nu finds which variables/functions are in scope and to what they are bound

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions