diff --git a/src/asm/fstack.cpp b/src/asm/fstack.cpp index 735cbf42..53276d7b 100644 --- a/src/asm/fstack.cpp +++ b/src/asm/fstack.cpp @@ -417,6 +417,14 @@ void fstk_RunMacro( macroName.c_str(), defType ); + } else if (std::shared_ptr firstArg = macroArgs->getArg(1); + firstArg && firstArg->starts_with(':')) { + error( + "Undefined macro `%s` (did you mean a label \"%s%s\"?)", + macroName.c_str(), + macroName.c_str(), + firstArg->starts_with("::") ? "::" : ":" + ); } else { error("Undefined macro `%s`", macroName.c_str()); } diff --git a/test/asm/lexer-hack.asm b/test/asm/lexer-hack.asm index 83e2d41b..553b058a 100644 --- a/test/asm/lexer-hack.asm +++ b/test/asm/lexer-hack.asm @@ -23,6 +23,6 @@ Label2: ld d, 4 ; and a label definition when already defined as a macro mac: ld e, 5 -; the space before the colon matters! +; the space before the colon matters! the space before the macro does not undef : -undef : +undef :: diff --git a/test/asm/lexer-hack.err b/test/asm/lexer-hack.err index f1b7c5ba..bce134ab 100644 --- a/test/asm/lexer-hack.err +++ b/test/asm/lexer-hack.err @@ -4,8 +4,8 @@ error: `mac` already defined at lexer-hack.asm(24) and also: at lexer-hack.asm(1) -error: Undefined macro `undef` +error: Undefined macro `undef` (did you mean a label "undef:"?) at lexer-hack.asm(27) -error: Undefined macro `undef` +error: Undefined macro `undef` (did you mean a label "undef::"?) at lexer-hack.asm(28) Assembly aborted with 4 errors!