Bug 24730 – Cannot initialize ref variable through `alias this`

Status
NEW
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2024-08-28T18:18:40Z
Last change time
2024-12-13T19:37:07Z
Assigned to
No Owner
Creator
Max Samukha
Moved to GitHub: dmd#20504 →

Comments

Comment #0 by maxsamukha — 2024-08-28T18:18:40Z
struct S {} struct S2 { S s; alias this = s; } void main() { S2 s2; ref S s = s2; } a.d(14): Error: type `S2` cannot be assigned to `ref S s`
Comment #1 by maxsamukha — 2024-08-28T18:23:57Z
Works with an explicit cast: ref S s = cast(S)s2;
Comment #2 by robert.schadek — 2024-12-13T19:37:07Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/20504 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB