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

Add macro methods for lib-related nodes #14218

Merged

Conversation

HertzDevil
Copy link
Contributor

Resolves part of #3274. Resolves #5244.

This covers LibDef, CStructOrUnionDef, FunDef, TypeDef, and ExternalVar. Most of those methods should be pretty straightforward, but some warrant a special mention:

  • FunDef#real_name, ExternalVar#real_name: These return a StringLiteral rather than a MacroId to minimize the chances that the caller forgets #stringify and produces invalid code. There is no way to distinguish between a node without a real name and a node whose real name is equal to its Crystal name, especially since Crystal::FunDef#real_name is not nilable.
  • FunDef#body, #has_body?: The former may return a Nop for both lib funs and top-level funs, so the latter is necessary.
  • CStructOrUnionDef#name, TypeDef#name: These return a Path rather than a MacroId to resemble AST nodes outside libs, even though syntactically they cannot be anything other than a single constant.

@straight-shoota straight-shoota added this to the 1.12.0 milestone Jan 15, 2024
@straight-shoota straight-shoota merged commit f8b5213 into crystal-lang:master Jan 16, 2024
57 checks passed
@HertzDevil HertzDevil deleted the feature/lib-macro-methods branch January 26, 2024 22:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add macro methods to lib-related nodes
2 participants