jfecher / ante

A safe, easy systems language
http://antelang.org
MIT License
1.9k stars 79 forks source link

Do nothing if the input file is empty #117

Closed mtshiba closed 2 years ago

mtshiba commented 2 years ago

This is a trivial problem, but the compiler crashed when I tried to compile an empty file.

$ ante empty.an
empty.an:1:1     error: failed trying to parse a term
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', src\error\mod.rs:203:79
stack backtrace:
...

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.

mtshiba commented 2 years ago

I made a mistake. I committed before the previous PR was merged.

I will close this PR once.