diff --git a/crates/analyzer/src/handlers/check_var_ref.rs b/crates/analyzer/src/handlers/check_var_ref.rs index 8817bf5a..e29a8e36 100644 --- a/crates/analyzer/src/handlers/check_var_ref.rs +++ b/crates/analyzer/src/handlers/check_var_ref.rs @@ -410,6 +410,7 @@ impl<'a> VerylGrammarTrait for CheckVarRef<'a> { }); } HandlerPoint::After => { + self.affiliation.pop(); self.assign_position.pop(); } } diff --git a/crates/analyzer/src/tests.rs b/crates/analyzer/src/tests.rs index f8d49586..8ae5c500 100644 --- a/crates/analyzer/src/tests.rs +++ b/crates/analyzer/src/tests.rs @@ -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]