Skip to content

Internal error: can't run a predeclaration without a body #11711

@nblumhardt

Description

@nblumhardt

Describe the bug

Hi! If parens rather than braces are used to define the body of a def, NuShell 0.89 will panic when invoking it:

Screenshot 2024-02-03 at 7 23 17 am

How to reproduce

def a () (echo 1)
a

Backtrace is:

thread 'main' panicked at /Users/nblumhardt/.cargo/registry/src/index.crates.io-6f17d22bba15001f/nu-protocol-0.89.0/src/signature.rs:650:9:
Internal error: can't run a predeclaration without a body
stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: <nu_protocol::signature::Predeclaration as nu_protocol::engine::command::Command>::run
   3: nu_engine::eval::eval_call
   4: nu_engine::eval::eval_expression_with_input
   5: nu_engine::eval::eval_element_with_input
   6: nu_engine::eval::eval_block
   7: nu_cli::util::eval_source
   8: nu_cli::repl::evaluate_repl
   9: nu::run::run_repl
  10: nu::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Expected behavior

Either reject the def or succeed when calling it.

Screenshots

No response

Configuration

key value
version 0.89.0
branch
commit_hash
build_os macos-aarch64
build_target aarch64-apple-darwin
rust_version rustc 1.75.0 (82e1608df 2023-12-21)
rust_channel stable-aarch64-apple-darwin
cargo_version cargo 1.75.0 (1d8b05cdd 2023-11-20)
build_time 2024-01-10 08:51:16 +10:00
build_rust_channel release
allocator mimalloc
features default, sqlite, trash, which, zip
installed_plugins

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions