From 9004d10df44335494eab9f7a3a040be1b877477f Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Sun, 21 Jun 2026 14:36:14 -0700 Subject: [PATCH] Handle invalid l-value indexed part select bases The l-value indexed part select path elaborates the base expression with `elab_and_eval()`. If the base expression can not be bound this returns a nullptr, but the l-value path dereferenced it while checking the expression type. For example, `a[does_not_exist -: 2] = 2'b00;` reported the bind error and then crashed. Return early when base elaboration fails. This matches the r-value indexed part select path and leaves the existing bind error as the reported elaboration error. Signed-off-by: Lars-Peter Clausen --- elab_lval.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/elab_lval.cc b/elab_lval.cc index 1068954d1..4d14fdb83 100644 --- a/elab_lval.cc +++ b/elab_lval.cc @@ -883,8 +883,10 @@ bool PEIdent::elaborate_lval_net_idx_(Design*des, calculate_up_do_width_(des, scope, wid); NetExpr*base = elab_and_eval(des, scope, index_tail.msb, -1); + if (!base) + return false; - if (base && base->expr_type() == IVL_VT_REAL) { + if (base->expr_type() == IVL_VT_REAL) { cerr << get_fileline() << ": error: Indexed part select base " "expression for "; cerr << lv->sig()->name() << "[" << *base;