Skip to content

Commit

Permalink
Fix hang on unterminated property decls.
Browse files Browse the repository at this point in the history
Bug: issue #1002
Test: new test case
  • Loading branch information
dvander committed Nov 29, 2024
1 parent 329bf95 commit d23897e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
7 changes: 7 additions & 0 deletions compiler/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1962,11 +1962,18 @@ Parser::parse_methodmap_property(MethodmapDecl* map)
if (!lexer_->need('{'))
return nullptr;

AutoCountErrors errors;

MemberFunctionDecl* getter = nullptr;
MemberFunctionDecl* setter = nullptr;
while (!lexer_->match('}')) {
if (!parse_methodmap_property_accessor(map, ident, type, &getter, &setter))
lexer_->lexclr(TRUE);
if (!lexer_->freading()) {
if (errors.ok())
lexer_->need('}');
break;
}
}

lexer_->require_newline(TerminatorPolicy::Newline);
Expand Down
2 changes: 2 additions & 0 deletions tests/compile-only/fail-incomplete-property-block.sp
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
methodmap A {
property int p {
1 change: 1 addition & 0 deletions tests/compile-only/fail-incomplete-property-block.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(3) : error 001: expected token: "public", but found "-end of file-"

0 comments on commit d23897e

Please sign in to comment.