Skip to content

Commit

Permalink
Merge pull request #1063 from taichi-ishitani/unexpected_unassigned_v…
Browse files Browse the repository at this point in the history
…ariable_error

Fix unexpected unassigned variable error
  • Loading branch information
dalance authored Nov 8, 2024
2 parents 97cd944 + 48ef1e2 commit dfc4cc0
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
1 change: 1 addition & 0 deletions crates/analyzer/src/handlers/check_var_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ impl<'a> VerylGrammarTrait for CheckVarRef<'a> {
});
}
HandlerPoint::After => {
self.affiliation.pop();
self.assign_position.pop();
}
}
Expand Down
39 changes: 39 additions & 0 deletions crates/analyzer/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1966,6 +1966,45 @@ fn unassign_variable() {

let errors = analyze(code);
assert!(errors.is_empty());

let code = r#"
module ModuleA {
var a: logic;
var b: logic;
always_comb {
a = b;
}
assign b = 0;
}
"#;

let errors = analyze(code);
assert!(errors.is_empty());

let code = r#"
module ModuleA (
o_d: output logic
) {
assign o_d = '0;
}
module ModuleB {
var a: logic;
var b: logic;
always_comb {
a = b;
}
inst u_sub: ModuleA (
o_d: b
);
}
"#;

let errors = analyze(code);
assert!(errors.is_empty());
}

#[test]
Expand Down

0 comments on commit dfc4cc0

Please sign in to comment.