Comment #3 by iamthewilsonator — 2018-08-14T13:28:27Z
At the very least the error message should not suck.
Comment #4 by iamthewilsonator — 2018-08-14T13:30:08Z
This triggers for ints as well.
extern(C) void main() {
auto a = [1];
}
same problem.
Comment #5 by iamthewilsonator — 2018-08-14T13:31:24Z
extern(C) void main() {
immutable a = [1];
}
works fine though.
Comment #6 by bugzilla — 2023-01-15T04:30:57Z
(In reply to Nicholas Wilson from comment #0)
> extern(C) void main() {
> enum string[] a = ["a"];
> auto aa = a; // line 3
> }
Now produces the error:
test.d(3): Error: expression `["a"]` uses the GC and cannot be used with switch `-betterC`
which is not bad. If we write this:
extern(C) void main() {
enum string[] a = ["a"];
auto aa = a[0];
}
it compiles without complaint. As far as I can see, this is expected behavior. The former produces the error because ["a"] has to be allocated somewhere at runtime, but with no GC, where should it be placed?
> At the very least the error message should not suck.
This condition is met, so I shall mark this as fixed.