Skip to content

Commit

Permalink
CORE: Fix crash when a type of global variables fails to parse
Browse files Browse the repository at this point in the history
  • Loading branch information
MineGame159 committed Jan 10, 2024
1 parent 8f0fad9 commit c212dbc
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions core/checker/declarations.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,11 @@ func (c *checker) VisitGlobalVar(decl *ast.GlobalVar) {
if ast.IsPrimitive(decl.Type, ast.Void) {
c.error(decl.Name, "Variable cannot be of type 'void'")
}

// Set type to void if its nil, for example because it failed to parse
if decl.Type == nil {
decl.Type = &ast.Primitive{Kind: ast.Void}
}
}

// Utils
Expand Down

0 comments on commit c212dbc

Please sign in to comment.