diff --git a/src/asm/lexer.cpp b/src/asm/lexer.cpp index 62210353..9574622d 100644 --- a/src/asm/lexer.cpp +++ b/src/asm/lexer.cpp @@ -797,11 +797,9 @@ static int peek() { } else if (c == '{' && !lexerState->disableInterpolation) { // If character is an open brace, do symbol interpolation shiftChar(); - if (auto str = readInterpolation(0); str) { beginExpansion(str, *str); } - return peek(); } @@ -1201,9 +1199,9 @@ static std::shared_ptr readInterpolation(size_t depth) { if (c == '{') { // Nested interpolation shiftChar(); - auto str = readInterpolation(depth + 1); - - beginExpansion(str, *str); + if (auto str = readInterpolation(depth + 1); str) { + beginExpansion(str, *str); + } continue; // Restart, reading from the new buffer } else if (c == EOF || c == '\r' || c == '\n' || c == '"') { error("Missing }\n"); diff --git a/test/asm/nested-bad-interpolation.asm b/test/asm/nested-bad-interpolation.asm new file mode 100644 index 00000000..50be43da --- /dev/null +++ b/test/asm/nested-bad-interpolation.asm @@ -0,0 +1,3 @@ +def p = {{a}} +def q = "{b}" +def r = "{{c}}" \ No newline at end of file diff --git a/test/asm/nested-bad-interpolation.err b/test/asm/nested-bad-interpolation.err new file mode 100644 index 00000000..10a6022a --- /dev/null +++ b/test/asm/nested-bad-interpolation.err @@ -0,0 +1,17 @@ +error: nested-bad-interpolation.asm(1): + Interpolated symbol "a" is a reserved keyword; add a '#' prefix to use it as a raw symbol +error: nested-bad-interpolation.asm(1): + Interpolated symbol "" does not exist +error: nested-bad-interpolation.asm(1): + syntax error, unexpected end of line +error: nested-bad-interpolation.asm(2): + Interpolated symbol "b" is a reserved keyword; add a '#' prefix to use it as a raw symbol +warning: nested-bad-interpolation.asm(2): [-Wobsolete] + Treating multi-unit strings as numbers is deprecated +error: nested-bad-interpolation.asm(3): + Interpolated symbol "c" is a reserved keyword; add a '#' prefix to use it as a raw symbol +error: nested-bad-interpolation.asm(3): + Interpolated symbol "" does not exist +warning: nested-bad-interpolation.asm(3): [-Wobsolete] + Treating multi-unit strings as numbers is deprecated +error: Assembly aborted (6 errors)!