Skip to content

Conversation

@rodrigogribeiro
Copy link
Collaborator

@rodrigogribeiro rodrigogribeiro commented Dec 12, 2025

This PR solves issue #226 by modifying the parser to only accept instance and contract functions which are fully type annotated. Almost all changes are due to make all test cases compile due to the parser change.

@mbenke
Copy link
Collaborator

mbenke commented Dec 22, 2025

I have two issues with this PR:

  1. The error message when missing return type is totally uninformative:
Parse error while processing lexeme: TLBrace
  1. Users will crucify us when they learn they have to write -> () for every void function (or else be greeted by the TLBrace message).

Point 1 perhaps may be solved as a part of a much needed general error-message overhaul.

Point 2 may be solved by defaulting to () when a required return type is omitted - I think we have discussed this, but don't remember the outcome and can't find it in our notes,
Maybe we should return to this in the next call.

One way to do this is in SolcoreParser.y:

  -- Around line 226, change AnnSignature to add a new rule for the omitted return type
  AnnSignature :: { Signature }
  AnnSignature : SigPrefix 'function' Name '(' AnnParamList ')' OptRetTyWithDefault
                 {Signature (fst $1) (snd $1) $3 $5 $7}

  -- Around line 293-294, replace RetTy with:
  OptRetTyWithDefault :: { Maybe Ty }
  OptRetTyWithDefault : '->' Type                    {Just $2}
                      | {- empty -}                  {Just unit}  -- default to unit type

Signed-off-by: Rodrigo Ribeiro <[email protected]>
@rodrigogribeiro rodrigogribeiro force-pushed the annotated-contract-instance-parser-error branch from 24eecb7 to 1e97116 Compare December 22, 2025 18:12
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