Thread overview | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
August 14, 2018 [Issue 19169] [betterC] bogus TypeInfo error for `enum string[] a = ["a"]; auto aa = a;` | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=19169 --- Comment #1 from Nicholas Wilson <iamthewilsonator@hotmail.com> --- Interestingly enum a = ["a"]; __gshared auto aa = a; extern(C) void main() {} Passes compilation just fine. -- |
August 14, 2018 [Issue 19169] [betterC] bogus TypeInfo error for `enum string[] a = ["a"]; auto aa = a;` | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=19169 Mike Franklin <slavo5150@yahoo.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |slavo5150@yahoo.com --- Comment #2 from Mike Franklin <slavo5150@yahoo.com> --- The problem is here: https://github.com/dlang/dmd/blob/48726c875fbfe16fd93051570d149e893d2dc3dc/src/dmd/e2ir.d#L5047-L5050 --- // call _d_arrayliteralTX(ti, dim) e = el_bin(OPcall, TYnptr, el_var(getRtlsym(RTLSYM_ARRAYLITERALTX)), el_param(el_long(TYsize_t, dim), getTypeInfo(ale.loc, ale.type, irs))); --- The compiler is generating a call to `_d_arrayliteralTX` in druntime: https://github.com/dlang/druntime/blob/9a8edfb48e4842180c706ee26ebd8edb10be53f4/src/rt/lifetime.d#L2279 That runtime hook requires a `TypeInfo` parameter. One solution would be to replace `_d_arrayliteralTX` with a template and a compile-time type parameter, but this issue does beg the question why it is even calling `_d_arrayliteralTX` in the first place. -- |
August 14, 2018 [Issue 19169] [betterC] bogus TypeInfo error for `enum string[] a = ["a"]; auto aa = a;` | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=19169 --- Comment #3 from Nicholas Wilson <iamthewilsonator@hotmail.com> --- At the very least the error message should not suck. -- |
August 14, 2018 [Issue 19169] [betterC] bogus TypeInfo error for `enum string[] a = ["a"]; auto aa = a;` | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=19169 --- Comment #4 from Nicholas Wilson <iamthewilsonator@hotmail.com> --- This triggers for ints as well. extern(C) void main() { auto a = [1]; } same problem. -- |
August 14, 2018 [Issue 19169] [betterC] bogus TypeInfo error for `enum string[] a = ["a"]; auto aa = a;` | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=19169 --- Comment #5 from Nicholas Wilson <iamthewilsonator@hotmail.com> --- extern(C) void main() { immutable a = [1]; } works fine though. -- |
June 04, 2022 [Issue 19169] [betterC] bogus TypeInfo error for `enum string[] a = ["a"]; auto aa = a;` | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=19169 Walter Bright <bugzilla@digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |betterC CC| |bugzilla@digitalmars.com -- |
December 17, 2022 [Issue 19169] [betterC] bogus TypeInfo error for `enum string[] a = ["a"]; auto aa = a;` | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=19169 Iain Buclaw <ibuclaw@gdcproject.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Priority|P1 |P4 -- |
January 15, 2023 [Issue 19169] [betterC] bogus TypeInfo error for `enum string[] a = ["a"]; auto aa = a;` | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=19169 Walter Bright <bugzilla@digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution|--- |FIXED --- Comment #6 from Walter Bright <bugzilla@digitalmars.com> --- (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. -- |
Copyright © 1999-2021 by the D Language Foundation