nushell / nushell

A new type of shell
https://www.nushell.sh/
MIT License
32.02k stars 1.65k forks source link

`def` allows closures in block #9737

Open sophiajt opened 1 year ago

sophiajt commented 1 year ago

Describe the bug

def foo [] { |x: int| 3 }

This should not parse as it's incorrect syntax for def

How to reproduce

  1. see above

Expected behavior

This should error

Screenshots

No response

Configuration

key value
version 0.82.1
branch main
commit_hash b693db16cc595ae7dba2bc52d1576fa80e58a110
build_os macos-aarch64
build_target aarch64-apple-darwin
rust_version rustc 1.68.2 (9eb3afe9e 2023-03-27)
rust_channel 1.68.2-aarch64-apple-darwin
cargo_version cargo 1.68.2 (6feb7c9cf 2023-03-26)
build_time 2023-07-15 19:13:57 +12:00
build_rust_channel release
allocator standard
features default, sqlite, trash, which, zip
installed_plugins

Additional context

No response

amtoine commented 1 year ago

we should have a cursed label for such a thing :eyes: :laughing:

WindSoilder commented 1 year ago

Should it be an error or expected behavior for now?

amtoine commented 1 year ago

Should it be an error or expected behavior for now?

i'd say the {...} is not a closure, but it's a block that allows mutations. so it should give a syntax error :thinking:

sophiajt commented 1 year ago

@WindSoilder - it should be an error to put the params on a def like that.