mirror of
https://github.com/luau-lang/luau.git
synced 2025-05-04 10:33:46 +01:00
Use the same error
This commit is contained in:
parent
8d0d271cd3
commit
8e409efde8
2 changed files with 9 additions and 3 deletions
|
@ -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_out_of_range_hex_integer = false;
|
||||||
bool lua_telemetry_parsed_double_prefix_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
|
namespace Luau
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -2206,6 +2208,11 @@ AstExpr* Parser::parseSimpleExpr()
|
||||||
nextLexeme();
|
nextLexeme();
|
||||||
return reportExprError(start, {}, "Malformed string");
|
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)
|
else if (lexer.current().type == Lexeme::Dot3)
|
||||||
{
|
{
|
||||||
if (functionStack.back().vararg)
|
if (functionStack.back().vararg)
|
||||||
|
@ -2682,7 +2689,7 @@ AstExpr* Parser::parseInterpString()
|
||||||
case Lexeme::BrokenString:
|
case Lexeme::BrokenString:
|
||||||
return reportExprError(location, {}, "Malformed interpolated string");
|
return reportExprError(location, {}, "Malformed interpolated string");
|
||||||
case Lexeme::BrokenInterpDoubleBrace:
|
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:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1045,7 +1045,7 @@ TEST_CASE_FIXTURE(Fixture, "parse_interpolated_string_double_brace_begin")
|
||||||
}
|
}
|
||||||
catch (const ParseErrors& e)
|
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)
|
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());
|
CHECK_EQ("Double braces are not permitted within interpolated strings. Did you mean '\\{'?", e.getErrors().front().getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue