Skip to content

Commit

Permalink
[Parser] don't crash if there is no main function
Browse files Browse the repository at this point in the history
  • Loading branch information
isuckatcs committed Jun 30, 2024
1 parent 69750b0 commit a3ac04e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -527,5 +527,5 @@ TheParser::parseSourceFile() {
if (!hasMainFunction && !incompleteAST)
error(nextToken.location, "main function not found");

return {std::move(functions), !incompleteAST};
return {std::move(functions), !incompleteAST && hasMainFunction};
}
2 changes: 2 additions & 0 deletions test/cfg/return.al
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,5 @@ fn foo(): number {
// CHECK-NEXT: [0 (exit)]
// CHECK-NEXT: preds: 1 2 3
// CHECK-NEXT: succs:

fn main(): void {}

0 comments on commit a3ac04e

Please sign in to comment.