Skip to content

Commit

Permalink
fix panic on check_var_ref checker
Browse files Browse the repository at this point in the history
(refs: #1127)
  • Loading branch information
taichi-ishitani committed Dec 7, 2024
1 parent 7324bb6 commit 9376cce
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
6 changes: 2 additions & 4 deletions crates/analyzer/src/handlers/check_var_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,9 @@ impl VerylGrammarTrait for CheckVarRef<'_> {
Direction::Output => ExpressionTargetType::OutputPort,
Direction::Inout => ExpressionTargetType::InoutPort,
Direction::Ref => ExpressionTargetType::RefPort,
_ => unreachable!(),
_ => return Ok(()),
},
_ => {
return Ok(());
}
_ => return Ok(()),
};
self.add_expression(&path, r#type);
}
Expand Down
20 changes: 20 additions & 0 deletions crates/analyzer/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2135,6 +2135,26 @@ fn invalid_factor_kind() {

let errors = analyze(code);
assert!(matches!(errors[0], AnalyzerError::InvalidFactor { .. }));

let code = r#"
interface InterfaceA {
var a: logic;
modport master {
a: input,
}
}
module ModuleA (
b: modport InterfaceA::master,
) {
var a: logic;
always_comb {
a = b;
}
}
"#;

let errors = analyze(code);
assert!(matches!(errors[0], AnalyzerError::InvalidFactor { .. }));
}

#[test]
Expand Down

0 comments on commit 9376cce

Please sign in to comment.