mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 07:35:42 +02:00
IR: Don't generate instructions for def
and export def
. (#14114)
# Description Fixes: #14110 Fixes: #14087 I think it's ok to not generating instruction to `def` and `export def` call. Because they just return `PipelineData::Empty` without doing anything. If nushell generates instructions for `def` and `export def`, nushell will try to capture variables for these block. It's not the time to do this. # User-Facing Changes ``` nu -c " def bar [] { let x = 1 ($x | foo) } def foo [] { foo } " ``` Will no longer raise error. # Tests + Formatting Added 4 tests
This commit is contained in:
@ -71,6 +71,9 @@ pub(crate) fn compile_call(
|
||||
"return" => {
|
||||
return compile_return(working_set, builder, call, redirect_modes, io_reg);
|
||||
}
|
||||
"def" | "export def" => {
|
||||
return builder.load_empty(io_reg);
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user