Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/arch/z80/visitor/translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ["<ERROR>"] # dummy placeholder so the compilation continues
Expand Down
Loading