diff --git a/Ast/src/Parser.cpp b/Ast/src/Parser.cpp index 7e5d8a65..6a0edd77 100644 --- a/Ast/src/Parser.cpp +++ b/Ast/src/Parser.cpp @@ -30,6 +30,8 @@ bool lua_telemetry_parsed_out_of_range_bin_integer = false; bool lua_telemetry_parsed_out_of_range_hex_integer = false; bool lua_telemetry_parsed_double_prefix_hex_integer = false; +#define ERROR_INVALID_INTERP_DOUBLE_BRACE "Double braces are not permitted within interpolated strings. Did you mean '\\{'?" + namespace Luau { @@ -2206,6 +2208,11 @@ AstExpr* Parser::parseSimpleExpr() nextLexeme(); return reportExprError(start, {}, "Malformed string"); } + else if (lexer.current().type == Lexeme::BrokenInterpDoubleBrace) + { + nextLexeme(); + return reportExprError(start, {}, ERROR_INVALID_INTERP_DOUBLE_BRACE); + } else if (lexer.current().type == Lexeme::Dot3) { if (functionStack.back().vararg) @@ -2682,7 +2689,7 @@ AstExpr* Parser::parseInterpString() case Lexeme::BrokenString: return reportExprError(location, {}, "Malformed interpolated string"); case Lexeme::BrokenInterpDoubleBrace: - return reportExprError(location, {}, "Double braces are not permitted within interpolated strings. Did you mean '\\{'?"); + return reportExprError(location, {}, ERROR_INVALID_INTERP_DOUBLE_BRACE); default: break; } diff --git a/tests/Parser.test.cpp b/tests/Parser.test.cpp index 3091f220..e0fe1d0f 100644 --- a/tests/Parser.test.cpp +++ b/tests/Parser.test.cpp @@ -1045,7 +1045,7 @@ TEST_CASE_FIXTURE(Fixture, "parse_interpolated_string_double_brace_begin") } catch (const ParseErrors& e) { - CHECK_EQ("Expected identifier when parsing expression, got '{{', which is invalid (did you mean '\\{'?)", e.getErrors().front().getMessage()); + CHECK_EQ("Double braces are not permitted within interpolated strings. Did you mean '\\{'?", e.getErrors().front().getMessage()); } } @@ -1060,7 +1060,6 @@ TEST_CASE_FIXTURE(Fixture, "parse_interpolated_string_double_brace_mid") } catch (const ParseErrors& e) { - // INTERP CODE REVIEW: It's weird for these two to have separate messages, but the one created by _begin is emergent from something else. CHECK_EQ("Double braces are not permitted within interpolated strings. Did you mean '\\{'?", e.getErrors().front().getMessage()); } }