Skip to content

Inconsistent "cannot be used as an lvalue in @safe code" deprecation #5519

Open
@dlangBugzillaToGithub

Description

@dlangBugzillaToGithub

Dennis reported this on 2024-07-15T14:01:20Z

Transferred from https://issues.dlang.org/show_bug.cgi?id=24664

Description

```
void main() @safe
{
    int[3] a;
    (cast(uint[3]) a)[0] = 20; // allowed 
    assert(a[0] == 20); // passes

    (cast(uint[3]) a) = [30, 40, 50]; // Deprecation: cast from `int[3]` to `uint[3]` cannot be used as an lvalue in @safe code
    assert(a[0] == 30);
}
```

Either both should compile, or neither.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions