diff --git a/src/arch/z80/visitor/translator.py b/src/arch/z80/visitor/translator.py index 66725c0d0..053880208 100644 --- a/src/arch/z80/visitor/translator.py +++ b/src/arch/z80/visitor/translator.py @@ -1029,7 +1029,9 @@ def default_value(cls, type_: symbols.TYPING, expr: symbols.EXPR) -> list[str]: if isinstance(type_, symbols.TYPEREF): type_ = type_.final - if expr.token in ("CONSTEXPR", "CONST"): # a constant expression like @label + 1 + if expr.token in ("CONSTEXPR", "CONST") or not check.is_number( + expr + ): # a constant expression like @label + 1, @a(0), etc. if type_ in (cls.TYPE(TYPE.float), cls.TYPE(TYPE.string)): error(expr.lineno, f"Can't convert non-numeric value to {type_.name} at compile time") return [""] # dummy placeholder so the compilation continues