Skip to content

Requiring type annotations in all top level functions#379

Merged
rodrigogribeiro merged 5 commits into
mainfrom
require-annotation-functions
May 14, 2026
Merged

Requiring type annotations in all top level functions#379
rodrigogribeiro merged 5 commits into
mainfrom
require-annotation-functions

Conversation

@rodrigogribeiro
Copy link
Copy Markdown
Collaborator

  • This PR makes all top level functions to require type annotations.
  • Fixes all test cases to use type annotations.

Copy link
Copy Markdown
Collaborator

@mbenke mbenke left a comment

Choose a reason for hiding this comment

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

Looks good, one minor point.

I am afraid the merge conflicts with other PRs might be brutal though.

Comment on lines +1212 to +1224
requireAnnotations :: FunDef Name -> TcM ()
requireAnnotations (FunDef sig@(Signature _ _ _ ps rt) _) =
unless (all isTyped ps && isJust rt) $
tcmError $
unlines
[ "Top-level function must have complete type annotations:",
" " ++ pretty sig,
"Annotate every parameter (name : Type) and provide a return type (-> Type)."
]
where
isTyped (Typed _ _) = True
isTyped _ = False

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.

This partly duplicates the code in fullSignature above, perhaps a shared helper like this may alleviate this:

isFullyAnnotated :: FunDef Name -> Bool
isFullyAnnotated (FunDef (Signature _ _ _ ps rt) _) =
    all isTyped ps && isJust rt
    where
      isTyped (Typed _ _) = True
      isTyped _ = False

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed.

@mbenke
Copy link
Copy Markdown
Collaborator

mbenke commented May 14, 2026

Also, the tests Compose.solc and Compose2.solc seem identical now:

$ diff -s test/examples/cases/Compose.solc test/examples/cases/Compose2.solc 
Files test/examples/cases/Compose.solc and test/examples/cases/Compose2.solc are identical

@rodrigogribeiro
Copy link
Copy Markdown
Collaborator Author

Also, the tests Compose.solc and Compose2.solc seem identical now:

$ diff -s test/examples/cases/Compose.solc test/examples/cases/Compose2.solc 
Files test/examples/cases/Compose.solc and test/examples/cases/Compose2.solc are identical

I removed Compose2.solc from the test suite.

@rodrigogribeiro rodrigogribeiro merged commit 74b24d4 into main May 14, 2026
4 checks passed
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.

2 participants