|
|
How do we present the code where an error occurred?
|
|
|
We could pretty print the AST nodes that we think caused the error, or we could actually read the source file.
|
|
|
|
|
|
At the moment the compiler uses the gnu error format.
|
|
|
|
|
|
I think that reading the source file is better because it preserves the formatting of the programmer.
|
|
|
|
|
|
It is probably a good idea to investigate how other programming languages present the locations where errors occurred.
|
|
|
|
|
|
Here is a first proposal:
|
|
|
|
|
|
```
|
|
|
In /home/qc/School/Advanced-Programming/Week-3/homework.sac
|
|
|
102| foo = bar + 1;
|
|
|
^^^
|
|
|
```
|
|
|
|
|
|
But since your only really compiling one file at a time we could maybe leave out the file location if the error happens in the source code of the file your compiling:
|
|
|
|
|
|
```
|
|
|
102| foo = bar + 1;
|
|
|
^^^
|
|
|
```
|
|
|
|
|
|
Sometimes the compiler just doesn't know where errors happened due to intense optimalization.
|
|
|
This should either be fixed or the compiler should at least be honest to the programmer saying something like:
|
|
|
|
|
|
```txt
|
|
|
I do not know from where in your code this error originated, sorry.
|
|
|
Try to check the stack trace for clues, add more logging, or isolate the issue in a smaller test case.
|
|
|
|
|
|
If all else fails, take a break, sometimes bugs hide better when you're tired.
|
|
|
```
|
|
|
## About Columns
|
|
|
|
|
|
We should decide whether to include columns in the error message because I don't really believe human actually use that when it is printed in error messages. However, humans do click on them though. |