From eaa719760274a8e2157e86cfa3cd40ef059dcd3d Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Sun, 21 Jun 2026 14:28:00 -0700 Subject: [PATCH] Handle bogus member l-value paths Currently the procedural l-value path asserts if symbol lookup leaves a member tail for a variable that is not a struct or class. For example, `r.bad = 1'b1;` where `r` is a scalar variable aborts during elaboration instead of reporting a normal error. Report an error for the leftover member path before the assertion. This matches the r-value path behavior for the same kind of invalid member access. Signed-off-by: Lars-Peter Clausen --- elab_lval.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/elab_lval.cc b/elab_lval.cc index 1068954d1..526b15d5b 100644 --- a/elab_lval.cc +++ b/elab_lval.cc @@ -298,6 +298,15 @@ NetAssign_*PEIdent::elaborate_lval_var_(Design *des, NetScope *scope, // Past this point, we should have taken care of the cases // where the name is a member/method of a struct/class. // XXXX ivl_assert(*this, method_name.nil()); + if (!tail_path.empty()) { + cerr << get_fileline() << ": error: Variable " + << reg->name() + << " does not have a field named: " + << tail_path << "." << endl; + des->errors += 1; + return nullptr; + } + ivl_assert(*this, tail_path.empty()); bool need_const_idx = is_cassign || is_force;