Different source code print when there are no columns
I recently merged !372 (merged) which added a print out of the source code where the error occurred in the error message.
That looks something like this:
./Extern.sac:14:9 abort:
13. int main() {
14. c = pow2(10);
↑
15. p("Hello, world!");
16. c = pow2(c);
However, after having used the new version with this feature for a bit I noticed that often the compiler actually does not have the column where the error happened. In that case the source code print out looks like this:
./Extern.sac:14: abort:
13. int main() {
14. c = pow2(10);
↑
15. p("Hello, world!");
16. c = pow2(c);
With this issue I want to suggest to print something different with the arrow when the compiler only has the line number. Here are my ideas so far:
^
symbols.
Underline the whole line with ./Extern.sac:14: abort:
13. int main() {
14. c = pow2(10);
^^^^^^^^^^^^^^^^^
15. p("Hello, world!");
16. c = pow2(c);
^
symbols but skip leading white space.
Underline the whole line with ./Extern.sac:14: abort:
13. int main() {
14. c = pow2(10);
^^^^^^^^^^^^^
15. p("Hello, world!");
16. c = pow2(c);
Right arrow at the start of the line.
./Extern.sac:14: abort:
13. int main() {
→ 14. c = pow2(10);
15. p("Hello, world!");
16. c = pow2(c);
Right arrow at the start of the line behind the line number.
./Extern.sac:14: abort:
13. int main() {
14. → c = pow2(10);
15. p("Hello, world!");
16. c = pow2(c);
Left arrow plus space at the end of the line:
./Extern.sac:14: abort:
13. int main() {
14. c = pow2(10); ←
15. p("Hello, world!");
16. c = pow2(c);
Combine left arrow before line number and ^ under line skipping white space on the left
./Extern.sac:14: abort:
13. int main() {
→ 14. c = pow2(10);
^^^^^^^^^^^^^
15. p("Hello, world!");
16. c = pow2(c);
I like Right arrow at the start of the line.
or Combine left arrow before line number and ^ under line skipping white space on the left
the most. I would love to hear some of your opinions and ideas.