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:
Jakub Žádník
2021-10-01 23:16:27 +03:00
parent 2af8116f50
commit 25b05dec9e
4 changed files with 18 additions and 12 deletions

View File

@ -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()