Better error for constant

This commit is contained in:
Kampfkarren 2022-07-26 19:48:09 -07:00
parent 8e409efde8
commit 12ca7c5bb0
2 changed files with 6 additions and 1 deletions

View file

@ -2213,6 +2213,11 @@ AstExpr* Parser::parseSimpleExpr()
nextLexeme();
return reportExprError(start, {}, ERROR_INVALID_INTERP_DOUBLE_BRACE);
}
else if (lexer.current().type == Lexeme::BrokenInterpNoFormat)
{
nextLexeme();
return reportExprError(start, {}, "Interpolated strings must contain expressions, and cannot be constant");
}
else if (lexer.current().type == Lexeme::Dot3)
{
if (functionStack.back().vararg)

View file

@ -1075,7 +1075,7 @@ TEST_CASE_FIXTURE(Fixture, "parse_interpolated_string_without_format")
}
catch (const ParseErrors& e)
{
CHECK_EQ("Expected identifier when parsing expression, got interpolated string with no formatting", e.getErrors().front().getMessage());
CHECK_EQ("Interpolated strings must contain expressions, and cannot be constant", e.getErrors().front().getMessage());
}
}