Closed mtshiba closed 2 years ago
I don't think a hard coded check for if the file length is 0 is the right way to solve this problem. The crash occurs on an unwrap
while reporting an error, so I pushed commit ea67b72 which solves it by changing it to unwrap_or("")
.
There remains the separate issue of running the compiler on an empty file (or one only filled with whitespace or comments) producing a parser error:
empty.an:1:1 error: failed trying to parse a term
I consider this a separate issue, so I'm closing this PR as the core issue is fixed.
This is a trivial problem, but the compiler crashed when I tried to compile an empty file.
In languages that do not have or require entry points, such as the main function, an empty file is often valid input and nothing is done as a result of execution.
So I've modified the compiler to immediately terminate if the input is an empty file.