Skip to content

add RefCast to Expressions #4164

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: master
Choose a base branch
from
Open

Conversation

WalterBright
Copy link
Member

Implementation PR: dlang/dmd#20728

@dlang-bot
Copy link
Contributor

Thanks for your pull request, @WalterBright!

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

Copy link
Contributor

@ntrel ntrel left a comment

Choose a reason for hiding this comment

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

)

$(P A $(I RefCast) takes a $(I UnaryExpression) representing an lvalue and forcibly changes
its type to $(I Type). It is equivalent to the expression $(D *cast(Type*)&UnaryExpression).
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
its type to $(I Type). It is equivalent to the expression $(D *cast(Type*)&UnaryExpression).
its type to $(I Type), producing an lvalue. It is equivalent to the expression $(D *cast(Type*) &UnaryExpression).

@0xEAB
Copy link
Member

0xEAB commented Aug 7, 2025

Should we call this BitCast instead maybe — to match the terminology found in Phobos?
AFAICT the corresponding DMD PR does not say “refcast”/“ref cast” anywhere either.

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.

5 participants