Skip to content
GitLab
  • Menu
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • sac2c sac2c
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 394
    • Issues 394
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 17
    • Merge requests 17
  • Deployments
    • Deployments
    • Releases
  • Wiki
    • Wiki
  • External wiki
    • External wiki
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • sac-group
  • sac2csac2c
  • Issues
  • #2478
Closed
Open
Created May 01, 2025 by Quinten Cabo@QuintenDeveloper

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:

Underline the whole line with ^ symbols.

./Extern.sac:14: abort:
  13. int main() {
  14.     c = pow2(10);
      ^^^^^^^^^^^^^^^^^
  15.     p("Hello, world!");
  16.     c = pow2(c);

Underline the whole line with ^ symbols but skip leading white space.

./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.

Edited May 01, 2025 by Quinten Cabo
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking