diff --git a/crates/nu-parser/src/parser.rs b/crates/nu-parser/src/parser.rs index cdcb4ed5ca..4b558d6317 100644 --- a/crates/nu-parser/src/parser.rs +++ b/crates/nu-parser/src/parser.rs @@ -954,12 +954,7 @@ pub fn parse_internal_call( let _ = working_set.add_span(call.head); let decl = working_set.get_decl(decl_id); - let signature = if let Some(block_id) = decl.block_id() { - let block = working_set.get_block(block_id); - *block.signature.clone() - } else { - decl.signature() - }; + let signature = working_set.get_signature(decl); let output = signature.get_output_type(); // storing the var ID for later due to borrowing issues diff --git a/crates/nu-protocol/src/engine/state_working_set.rs b/crates/nu-protocol/src/engine/state_working_set.rs index 822bf35e3a..6a48238e99 100644 --- a/crates/nu-protocol/src/engine/state_working_set.rs +++ b/crates/nu-protocol/src/engine/state_working_set.rs @@ -5,7 +5,7 @@ use crate::{ StateDelta, Variable, VirtualPath, Visibility, }, BlockId, Category, CompileError, Config, DeclId, FileId, GetSpan, Module, ModuleId, ParseError, - ParseWarning, Span, SpanId, Type, Value, VarId, VirtualPathId, + ParseWarning, Signature, Span, SpanId, Type, Value, VarId, VirtualPathId, }; use core::panic; use std::{ @@ -708,6 +708,14 @@ impl<'a> StateWorkingSet<'a> { } } + pub fn get_signature(&self, decl: &dyn Command) -> Signature { + if let Some(block_id) = decl.block_id() { + *self.get_block(block_id).signature.clone() + } else { + decl.signature() + } + } + pub fn find_commands_by_predicate( &self, predicate: impl Fn(&[u8]) -> bool,