mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 18:22:07 +00:00
Improve the error messages for interpolating undefined or invalid symbols (#1423)
This commit is contained in:
@@ -1208,7 +1208,7 @@ static std::shared_ptr<std::string> readInterpolation(size_t depth) {
|
|||||||
|
|
||||||
Symbol const *sym = sym_FindScopedValidSymbol(fmtBuf);
|
Symbol const *sym = sym_FindScopedValidSymbol(fmtBuf);
|
||||||
|
|
||||||
if (!sym) {
|
if (!sym || !sym->isDefined()) {
|
||||||
error("Interpolated symbol \"%s\" does not exist\n", fmtBuf.c_str());
|
error("Interpolated symbol \"%s\" does not exist\n", fmtBuf.c_str());
|
||||||
} else if (sym->type == SYM_EQUS) {
|
} else if (sym->type == SYM_EQUS) {
|
||||||
auto buf = std::make_shared<std::string>();
|
auto buf = std::make_shared<std::string>();
|
||||||
@@ -1219,7 +1219,7 @@ static std::shared_ptr<std::string> readInterpolation(size_t depth) {
|
|||||||
fmt.appendNumber(*buf, sym->getConstantValue());
|
fmt.appendNumber(*buf, sym->getConstantValue());
|
||||||
return buf;
|
return buf;
|
||||||
} else {
|
} else {
|
||||||
error("Only numerical and string symbols can be interpolated\n");
|
error("Interpolated symbol \"%s\" is not a numeric or string symbol\n", fmtBuf.c_str());
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
SECTION "Test", ROM0
|
SECTION "Test", ROM0[123]
|
||||||
|
|
||||||
def NAME equs "ITEM"
|
def NAME equs "ITEM"
|
||||||
def FMT equs "d"
|
def FMT equs "d"
|
||||||
@@ -14,6 +14,15 @@ PRINTLN STRCAT("{NAME}_{d:INDEX}", " is ", {NAME}_{d:INDEX})
|
|||||||
PURGE {NAME}_{d:INDEX}
|
PURGE {NAME}_{d:INDEX}
|
||||||
ASSERT !DEF({NAME}_{d:INDEX})
|
ASSERT !DEF({NAME}_{d:INDEX})
|
||||||
|
|
||||||
|
; undefined
|
||||||
|
PRINTLN "undef {undef}"
|
||||||
|
|
||||||
|
; referenced but undefined
|
||||||
|
ld hl, label
|
||||||
|
PRINTLN "label {label}"
|
||||||
|
label::
|
||||||
|
PRINTLN "label {label}"
|
||||||
|
|
||||||
; not string or number
|
; not string or number
|
||||||
MACRO foo
|
MACRO foo
|
||||||
ENDM
|
ENDM
|
||||||
|
|||||||
@@ -1,3 +1,7 @@
|
|||||||
error: interpolation.asm(20):
|
error: interpolation.asm(18):
|
||||||
Only numerical and string symbols can be interpolated
|
Interpolated symbol "undef" does not exist
|
||||||
error: Assembly aborted (1 error)!
|
error: interpolation.asm(22):
|
||||||
|
Interpolated symbol "label" does not exist
|
||||||
|
error: interpolation.asm(29):
|
||||||
|
Interpolated symbol "foo" is not a numeric or string symbol
|
||||||
|
error: Assembly aborted (3 errors)!
|
||||||
|
|||||||
@@ -1,2 +1,5 @@
|
|||||||
ITEM_100 is hundredth
|
ITEM_100 is hundredth
|
||||||
|
undef
|
||||||
|
label
|
||||||
|
label $7E
|
||||||
foo
|
foo
|
||||||
|
|||||||
Reference in New Issue
Block a user