forked from extern/nushell
Fix panic on double def; Tests; Double def error
* Fixes a panic with defining two commands with the same name caused by declaration not found after predeclaration. * Adds a new error if a custom command is defined more than once in one block. * Add some tests
This commit is contained in:
@ -2606,16 +2606,18 @@ pub fn parse_block(
|
||||
working_set.enter_scope();
|
||||
}
|
||||
|
||||
let mut error = None;
|
||||
|
||||
// Pre-declare any definition so that definitions
|
||||
// that share the same block can see each other
|
||||
for pipeline in &lite_block.block {
|
||||
if pipeline.commands.len() == 1 {
|
||||
parse_def_predecl(working_set, &pipeline.commands[0].parts);
|
||||
if let Some(err) = parse_def_predecl(working_set, &pipeline.commands[0].parts) {
|
||||
error = error.or(Some(err));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let mut error = None;
|
||||
|
||||
let block: Block = lite_block
|
||||
.block
|
||||
.iter()
|
||||
|
Reference in New Issue
Block a user