IR: fix incorrect capturing of subexpressions
This commit is contained in:
parent
53fbf62493
commit
abfe0be537
|
@ -444,7 +444,15 @@ pub(crate) fn compile_expression(
|
||||||
working_set,
|
working_set,
|
||||||
builder,
|
builder,
|
||||||
&full_cell_path.head,
|
&full_cell_path.head,
|
||||||
RedirectModes::capture_out(expr.span),
|
// Only capture the output if there is a tail. This was a bit of a headscratcher
|
||||||
|
// as the parser emits a FullCellPath with no tail for subexpressions in
|
||||||
|
// general, which shouldn't be captured any differently than they otherwise
|
||||||
|
// would be.
|
||||||
|
if !full_cell_path.tail.is_empty() {
|
||||||
|
RedirectModes::capture_out(expr.span)
|
||||||
|
} else {
|
||||||
|
redirect_modes
|
||||||
|
},
|
||||||
in_reg,
|
in_reg,
|
||||||
out_reg,
|
out_reg,
|
||||||
)?;
|
)?;
|
||||||
|
|
|
@ -209,6 +209,12 @@ fn run_glob_if_pass_variable_to_external() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn subexpression_does_not_implicitly_capture() {
|
||||||
|
let actual = nu!("(nu --testbin cococo); null");
|
||||||
|
assert_eq!(actual.out, "cococo");
|
||||||
|
}
|
||||||
|
|
||||||
mod it_evaluation {
|
mod it_evaluation {
|
||||||
use super::nu;
|
use super::nu;
|
||||||
use nu_test_support::fs::Stub::{EmptyFile, FileWithContent, FileWithContentToBeTrimmed};
|
use nu_test_support::fs::Stub::{EmptyFile, FileWithContent, FileWithContentToBeTrimmed};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user