Skip to content

Conversation

mbenke
Copy link
Collaborator

@mbenke mbenke commented Sep 3, 2025

Quick and dirty string literal handling - literals longer than 32 chars are truncated

@mbenke mbenke requested a review from d-xo September 3, 2025 12:31
, SFunction <$> (pKeyword "function" *> identifier) <*> (parens (commaSep coreArg)) <*> (symbol "->" *> coreType)
<*> (symbol "{" *> many coreStmt <* symbol "}")
, SAssembly <$> (pKeyword "assembly" *> yulBlock)
, SRevert <$> (pKeyword "revert" *> stringLiteral)
Copy link
Contributor

Choose a reason for hiding this comment

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

why?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Don't know if we need revert builtin in core, but I renamed it to __revert__, because otherwise you cannot define a function called revert

Just e -> pure (e, [])
Nothing -> pure (Core.EVar (unwrapId x), [])
-- special handling of revert
emitExp (Call _ (Id "revert" _) [Lit(StrLit s)]) = pure(Core.EUnit, [Core.SRevert s])
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this supposed to be commented?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, I have disabled special handling of revert.
Another option might be to keep special handling of revert and transform string literals on the Core <-> Yul stage.

But the current typechecker chokes on type literals, so I decided to do it in the preliminar desugaring stage, at least for now.

@mbenke
Copy link
Collaborator Author

mbenke commented Sep 4, 2025

For comnparison, I will try another approach, keeping string literals throughout the frontend and desugaring them in the backend.

@mbenke mbenke marked this pull request as draft September 10, 2025 06:29
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