Skip to content

Improve diagnostics#416

Open
Y-Nak wants to merge 36 commits into
argotorg:mainfrom
Y-Nak:improve-diagnostics
Open

Improve diagnostics#416
Y-Nak wants to merge 36 commits into
argotorg:mainfrom
Y-Nak:improve-diagnostics

Conversation

@Y-Nak

@Y-Nak Y-Nak commented May 26, 2026

Copy link
Copy Markdown
Member

Improve compiler diagnostics.
This PR adds structured diagnostics and source spans in more places, so errors can show file, line, column and labels.

Remaining things that should be addressed later are:

  • some old tcmError / SC0299 errors are still there
  • some fallback span guessing is still used
  • location tests are not perfect, they do not check every span is preserved exactly

@mbenke mbenke left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In some cases the error message is repeated, e.g.

$ esolc tmp/unsafeFromWord.solc 
tmp/unsafeFromWord.solc
error: module typecheck failed for /home/ben/work/review/tmp/unsafeFromWord.solc (no desugaring):
Type not polymorphic enough! The annotated type is:
forall a . word -> a
but the infered type is:
word -> word
in:
forall a . function fromWord (x : word) -> a

 - in:forall a . function fromWord (x : word) -> a {
   let result ;
   assembly {
      result := x
   }
   return result;
}
  ──> /home/ben/work/review/tmp/unsafeFromWord.solc:3:30
  │
3 │       assembly { result := x } 
  │                              ^ module typecheck failed for /home/ben/work/review/tmp/unsafeFromWord.solc (no desugaring):
Type not polymorphic enough! The annotated type is:
forall a . word -> a
but the infered type is:
word -> word
in:
forall a . function fromWord (x : word) -> a

 - in:forall a . function fromWord (x : word) -> a {
   let result ;
   assembly {
      result := x
   }
   return result;
}

@Y-Nak Y-Nak marked this pull request as ready for review May 28, 2026 15:25
@Y-Nak Y-Nak requested review from mbenke and rodrigogribeiro May 28, 2026 15:25

@rodrigogribeiro rodrigogribeiro left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous comment on the codes used is not a blocker: I just want to understand the logic behind the choice for the codes.

Great work!

(moduleReferenceHelp code)

moduleReferenceLabelMessage :: String -> String -> String
moduleReferenceLabelMessage "SC0118" _ = "external library import"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be an enumeration instead of a String?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants