Only get one error rather than two

This commit is contained in:
Kampfkarren 2022-08-17 16:51:17 -07:00
parent 3b26ab85a0
commit 83dad7bdf3
2 changed files with 4 additions and 0 deletions

View file

@ -2778,8 +2778,10 @@ AstExpr* Parser::parseInterpString()
case Lexeme::InterpStringEnd:
break;
case Lexeme::BrokenInterpDoubleBrace:
nextLexeme();
return reportExprError(location, {}, ERROR_INVALID_INTERP_DOUBLE_BRACE);
case Lexeme::BrokenString:
nextLexeme();
return reportExprError(location, {}, "Malformed interpolated string, did you forget to add a '}'?");
default:
return reportExprError(location, {}, "Malformed interpolated string, got %s", lexer.current().toString().c_str());

View file

@ -953,6 +953,8 @@ TEST_CASE_FIXTURE(Fixture, "parse_interpolated_string_without_end_brace")
}
catch (const ParseErrors& e)
{
CHECK_EQ(e.getErrors().size(), 1);
auto error = e.getErrors().front();
CHECK_EQ("Malformed interpolated string, did you forget to add a '}'?", error.getMessage());
return error.getLocation().begin.column;