Skip to content

export const with a type signature causes Internal error: failed to find added variable #14023

Closed

Description

@aionescu

Describe the bug

Declaring an export const with a type signature inside a module results in an Internal error being thrown with the message failed to find added variable.

How to reproduce

At the REPL, try to define the following module:

> module foo { export const FOO: int = 2 }
Error: nu::parser::unknown_state

  × Internal error.
   ╭─[entry #1:1:21]
 1 │ module foo { export const FOO: int = 2 }
   ·                     ─────────┬────────
   ·                              ╰── failed to find added variable
   ╰────

Alternatively, define the module in a file named foo.nu and try to use it from the REPL:

# foo.nu
export const FOO: int = 2
# REPL
> use foo.nu
Error: nu::parser::unknown_state

  × Internal error.
   ╭─[/path/to/foo.nu:1:8]
 1 │ export const FOO: int = 2
   ·        ─────────┬────────
   ·                 ╰── failed to find added variable
   ╰────

The error is only produced if the const has both export and a type signature. The specific type in the signature doesn't seem to matter.

The issue occurs even when running Nu with --no-config-file --no-std-lib.

Expected behavior

I expected module foo to be defined without issue.

Configuration

key value
version 0.98.0
major 0
minor 98
patch 0
branch makepkg
commit_hash 6e1e824
build_os linux-x86_64
build_target x86_64-unknown-linux-gnu
rust_version rustc 1.81.0 (eeb90cda1 2024-09-04) (Arch Linux rust 1:1.81.0-1)
cargo_version cargo 1.81.0 (2dbb1af80 2024-08-20)
build_time 2024-09-18 13:20:08 +00:00
build_rust_channel release
allocator mimalloc
features default, sqlite, trash
installed_plugins

Activity

  1. added
    status:needs-triage
    on Oct 7, 2024
  2. added
    category:bug
    A:modules
    on Oct 7, 2024
  3. added
    A:parser
    on Oct 7, 2024
  4. modified the milestone: v0.100.0 on Oct 22, 2024
  5. added a commit that references this issue on Oct 22, 2024
    4968b6b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A:modulesA:parsercategory:bugstatus:needs-triage

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions