dmd icon indicating copy to clipboard operation
dmd copied to clipboard

fix(preview=in|rvaluerefparam): Allow int to uint implicit conversion

Open Geod24 opened this issue 6 months ago • 2 comments

One would expect that a CT-known value such as 42 can implicitly convert to 'ref uint' when rvalue-ref preview switches are on.

Geod24 avatar May 26 '25 13:05 Geod24

Thanks for your pull request, @Geod24!

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.

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "master + dmd#21412"

dlang-bot avatar May 26 '25 13:05 dlang-bot

I need to revisit this. After looking at the failing test, it raises the question whether foo("1234"); void foo(ref char[4]); should compile with -preview=rvaluerefparam. It could - because we can create a temporary and pass it to foo without memory allocation. However, that would be a bit surprising. -preview=in doesn't have that problem because it's always const, and foo("1234"); void foo(ref const char[4]); already compiles.

Geod24 avatar May 27 '25 08:05 Geod24