Skip to content

Commit

Permalink
fixing bug in conditional creation of components inside loops
Browse files Browse the repository at this point in the history
  • Loading branch information
clararod9 committed Jun 2, 2022
1 parent ae33f6a commit c15805f
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion compiler/src/hir/component_preprocess.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ fn rm_statement(stmt: &mut Statement) {
rm_block(stmt);
} else if stmt.is_initialization_block() {
rm_init(stmt);
} else {
} else if stmt.is_substitution(){
rm_substitution(stmt);
}
else{
}
}

Expand Down Expand Up @@ -73,6 +76,15 @@ fn rm_init(stmt: &mut Statement) {
}
}

fn rm_substitution(stmt: &mut Statement){
use Statement::{Block, Substitution};
if should_be_removed(stmt){
if let Substitution { meta, .. } = stmt{
*stmt = Block{ meta: meta.clone(), stmts: Vec::new() };
}
}
}

fn should_be_removed(stmt: &Statement) -> bool {
use Statement::{InitializationBlock, Substitution};
use VariableType::*;
Expand Down

0 comments on commit c15805f

Please sign in to comment.