Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Definition of a pragma for boolean type. #48

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

rodrigogribeiro
Copy link
Collaborator

Initial implementation for a pragma for setting up the boolean type. Current syntax definition:

data bool = true | false;

pragma bool-type-decl bool, true, false;

@mbenke
Copy link
Collaborator

mbenke commented Dec 2, 2024

What's the intended meaning? To translate declared true/false to Yul true/false/ Anything else?
Perhaps also if/while when we have them? Maybe we should think how they should work.

@rodrigogribeiro
Copy link
Collaborator Author

What's the intended meaning? To translate declared true/false to Yul true/false/ Anything else? Perhaps also if/while when we have them? Maybe we should think how they should work.

That's my main question: What should I do with this information? Should I add if / while statements to the surface syntax?

Copy link
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.

It's very hard to tell what changed when actual changes are mixed with big reformatting. Could you please split this PR in two (reformatting, actual pragma stuff)?

Comment on lines +18 to +22
data PragmaStatus
= Enabled
| DisableAll
| DisableFor (NonEmpty Name)
deriving (Eq, Ord, Show, Data, Typeable)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't know what PragmaStatus is, please add comment in code

@mbenke
Copy link
Collaborator

mbenke commented Dec 10, 2024

Something is missign in prettyprinter:

$ cabal run -- sol-core -v -f test/examples/pragmas/booltypesyntax.solc
> AST after name resolution
sol-core: src/Solcore/Frontend/Pretty/SolcorePretty.hs:(56,3)-(58,46): Non-exhaustive patterns in function ppr

Comment on lines +55 to +58
instance Pretty Pragma where
ppr (InferencePragma _ Enabled) = empty
ppr (InferencePragma ty st) =
hsep [text "pragma", ppr ty, ppr st, semi]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
instance Pretty Pragma where
ppr (InferencePragma _ Enabled) = empty
ppr (InferencePragma ty st) =
hsep [text "pragma", ppr ty, ppr st, semi]
instance Pretty Pragma where
ppr (InferencePragma _ Enabled) = empty
ppr (InferencePragma ty st) =
hsep [text "pragma", ppr ty, ppr st, semi]
ppr (BoolTypePragma (ty N.:| cons)) =
text "pragma bool-type-decl" <+> commaSep (map ppr (ty:cons))

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