Skip to content

Refactor proc macros into v2 #1495

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

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

Conversation

ericnordelo
Copy link
Member

Fixes #1485

PR Checklist

  • Tests
  • Documentation
  • Added entry to CHANGELOG.md
  • Tried the feature on a public network

@ericnordelo ericnordelo requested review from immrsd and Copilot August 13, 2025 12:12
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Collaborator

@immrsd immrsd left a comment

Choose a reason for hiding this comment

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

Left a couple of comments
Also, could you explain the idea behind removing all the comments from the generated code?

Comment on lines +55 to +58
"DAPP_NAME"
}

fn version() -> felt252 {
'DAPP_VERSION'
"DAPP_VERSION"
Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe the implementation with ByteArray literals instead of felt252 literals won't be able to compile
Can we add a check that all the generated contracts compile without issues?

Copy link
Member Author

Choose a reason for hiding this comment

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

It won't, but we don't need them to compile here, we just need the macro to generate the correct code. We don't need to add a check for compilation, since the macro is not in charge of that.

Note that using a ByteArray is a temporal solution until the proc macro bug of not accepting shortstrings gets fixed.

'DAPP_NAME'
"DAPP_NAME"
}
fn version() -> felt252 {
'DAPP_VERSION'
"DAPP_VERSION"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same issue with literals of a wrong type here

@ericnordelo
Copy link
Member Author

Also, could you explain the idea behind removing all the comments from the generated code?

Sadly it is not intentional, but the quote! macro does remove them automatically. Haven't found a solution for it yet, but since we need to refactor to use proper Text Spans for v2, maybe (hopefully) that would solve the issue with comments as well.

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.

Refactor macros package to use cairo-lang-macro: v2
2 participants