diff --git a/frontends/rtlil/rtlil_frontend.cc b/frontends/rtlil/rtlil_frontend.cc index b54cd8f14..04d01fc93 100644 --- a/frontends/rtlil/rtlil_frontend.cc +++ b/frontends/rtlil/rtlil_frontend.cc @@ -324,29 +324,27 @@ struct RTLILFrontendWorker { RTLIL::SigSpec parse_sigspec() { + RTLIL::SigSpec sig; + if (try_parse_char('{')) { std::vector parts; while (!try_parse_char('}')) parts.push_back(parse_sigspec()); - RTLIL::SigSpec sig; for (auto it = parts.rbegin(); it != parts.rend(); ++it) sig.append(std::move(*it)); - return sig; - } - - RTLIL::SigSpec sig; - - // We could add a special path for parsing IdStrings that must already exist, - // as here. - // We don't need to addref/release in this case. - std::optional id = try_parse_id(); - if (id.has_value()) { - RTLIL::Wire *wire = current_module->wire(*id); - if (wire == nullptr) - error("Wire `%s' not found.", *id); - sig = RTLIL::SigSpec(wire); } else { - sig = RTLIL::SigSpec(parse_const()); + // We could add a special path for parsing IdStrings that must already exist, + // as here. + // We don't need to addref/release in this case. + std::optional id = try_parse_id(); + if (id.has_value()) { + RTLIL::Wire *wire = current_module->wire(*id); + if (wire == nullptr) + error("Wire `%s' not found.", *id); + sig = RTLIL::SigSpec(wire); + } else { + sig = RTLIL::SigSpec(parse_const()); + } } while (try_parse_char('[')) { diff --git a/tests/rtlil/bug5424.ys b/tests/rtlil/bug5424.ys new file mode 100644 index 000000000..a0b0638e5 --- /dev/null +++ b/tests/rtlil/bug5424.ys @@ -0,0 +1,12 @@ +read_rtlil <