tracer: return default name on unrecognized opcode.

The default name is more commonly returned on code such as:

    x, y = Signal(), Signal()

The case where the opcode is not recognized is only encountered
when older Amaranth is ran on a newer Python interpreter (with more
opcodes).

Returning None instead of a name here caused issues in the RTLIL
backend, which would incorrectly use $\d+ names for ports, since
the RTLIL backend assumed the name of a signal is always a string.

Fixes #733.
This commit is contained in:
Catherine 2023-01-31 10:32:44 +00:00
parent 2ca421dea8
commit aaec7e0d27

View file

@ -24,8 +24,9 @@ def get_var_name(depth=2, default=_raise_exception):
call_index += 2
else:
break
if call_opc not in ("CALL_FUNCTION", "CALL_FUNCTION_KW", "CALL_FUNCTION_EX", "CALL_METHOD", "CALL"):
return None
if call_opc not in ("CALL_FUNCTION", "CALL_FUNCTION_KW", "CALL_FUNCTION_EX",
"CALL_METHOD", "CALL"):
return default
index = call_index + 2
while True: