mirror of
https://github.com/nushell/nushell.git
synced 2025-05-09 12:34:26 +02:00
Merge 5d6b26d98d
into a0d7c1a4fd
This commit is contained in:
commit
90b7b89deb
@ -5,8 +5,9 @@
|
||||
use crate::{
|
||||
ast::{Assignment, Block, Call, Expr, Expression, ExternalArgument},
|
||||
debugger::{DebugContext, WithoutDebug},
|
||||
engine::{EngineState, StateWorkingSet},
|
||||
engine::{Closure, EngineState, StateWorkingSet},
|
||||
eval_base::Eval,
|
||||
ir::Instruction,
|
||||
record, BlockId, Config, HistoryFileFormat, PipelineData, Record, ShellError, Span, Value,
|
||||
VarId,
|
||||
};
|
||||
@ -548,12 +549,41 @@ impl Eval for EvalConst {
|
||||
}
|
||||
|
||||
fn eval_row_condition_or_closure(
|
||||
_: &StateWorkingSet,
|
||||
state: &StateWorkingSet,
|
||||
_: &mut (),
|
||||
_: BlockId,
|
||||
block_id: BlockId,
|
||||
span: Span,
|
||||
) -> Result<Value, ShellError> {
|
||||
Err(ShellError::NotAConstant { span })
|
||||
let block = state.get_block(block_id);
|
||||
let ir_block = block
|
||||
.ir_block
|
||||
.as_ref()
|
||||
.ok_or(ShellError::NotAConstant { span })?;
|
||||
|
||||
let non_const_var_idx = ir_block.instructions.iter().position(|ins| {
|
||||
let Instruction::LoadVariable { var_id, .. } = ins else {
|
||||
return false;
|
||||
};
|
||||
let var = state.get_variable(*var_id);
|
||||
!(var.const_val.is_some()
|
||||
|| block
|
||||
.span
|
||||
.is_some_and(|b| b.contains_span(var.declaration_span)))
|
||||
});
|
||||
|
||||
if let Some(idx) = non_const_var_idx {
|
||||
Err(ShellError::NotAConstant {
|
||||
span: ir_block.spans[idx],
|
||||
})
|
||||
} else {
|
||||
Ok(Value::closure(
|
||||
Closure {
|
||||
block_id,
|
||||
captures: vec![],
|
||||
},
|
||||
span,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
fn eval_overlay(_: &StateWorkingSet, span: Span) -> Result<Value, ShellError> {
|
||||
|
Loading…
Reference in New Issue
Block a user