[Issue 20142] New: Reading member of enum considered modifying access

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Aug 19 13:01:52 UTC 2019


https://issues.dlang.org/show_bug.cgi?id=20142

          Issue ID: 20142
           Summary: Reading member of enum considered modifying access
           Product: D
           Version: D2
          Hardware: All
                OS: Linux
            Status: NEW
          Severity: regression
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: rschadek at symmetryinvestments.com

This fails to compile with

```
import std.array : empty;

struct Foo {
    string text;
}

Foo getFoo() {
    return Foo("Hello World");
}

void main() {
    enum Foo foo = getFoo();
    assert(!foo.text.empty);
}
```
(13): Error: cannot modify constant expression Foo("Hello World").text

--


More information about the Digitalmars-d-bugs mailing list