Improve the error messages for interpolating undefined or invalid symbols (#1423)

This commit is contained in:
Sylvie
2024-07-25 17:36:02 -04:00
committed by GitHub
parent e179ba5fd3
commit 13a8895fca
4 changed files with 22 additions and 6 deletions

View File

@@ -1208,7 +1208,7 @@ static std::shared_ptr<std::string> readInterpolation(size_t depth) {
Symbol const *sym = sym_FindScopedValidSymbol(fmtBuf);
if (!sym) {
if (!sym || !sym->isDefined()) {
error("Interpolated symbol \"%s\" does not exist\n", fmtBuf.c_str());
} else if (sym->type == SYM_EQUS) {
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());
return buf;
} 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;
}