Skip to content

it is somehow a special variable in closure (since 0.92) #12690

@wdv4758h

Description

@wdv4758h

Describe the bug

See more info in discussion link.

Discussed in #12440

Originally posted by wdv4758h April 7, 2024
With 0.92, it seems that it is treated differently.

This print 42 in 0.91, but gets error in 0.92.

let tmp = {
  let it = 42
  print $it
}

do -c $tmp

errors in 0.92:

  × Missing parameter: $it.
   ╭─[example.nu:6:1]
 5 │ 
 6 │ do -c $tmp
   · ─┬
   ·  ╰── missing parameter: $it
   ╰────

This print 42 in both 0.91 and 0.92.

let tmp = {
  let x = 42
  print $x
}

do -c $tmp

How to reproduce

See above code.

Expected behavior

Works without error.

Screenshots

No response

Configuration

key value
version 0.92.3
major 0
minor 92
patch 3
branch nightly
commit_hash 24ecb84
build_os linux-x86_64
build_target x86_64-unknown-linux-gnu
rust_version rustc 1.77.2 (25ef9e3d8 2024-04-09)
rust_channel 1.77.2-x86_64-unknown-linux-gnu
cargo_version cargo 1.77.2 (e52e36006 2024-03-26)
build_time 2024-04-28 01:44:34 +00:00
build_rust_channel release
allocator mimalloc
features dataframe, default, sqlite, static-link-openssl, system-clipboard, trash, which
installed_plugins query

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    A:scoping/name-resolutionHow Nu finds which variables/functions are in scope and to what they are boundcategory:bugSomething isn't workingcategory:regressionSomething that worked does not work anymore.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions