Thread overview | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
April 04, 2022 [Issue 22981] Another forward reference bug involving a string mixin | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=22981 --- Comment #1 from Max Samukha <maxsamukha@gmail.com> --- (In reply to Max Samukha from comment #0) > The test case compiles if the enum is wrapped in a template: However, it doesn't if the template instance is aliased: template E_() { mixin ("enum E_ {", S.attr, "}"); } alias E = E_!(); struct S { E e; enum attr = "a"; } onlineapp.d(12): Error: template instance `onlineapp.E_!()` is used as a type onlineapp.d(8): Error: template instance `onlineapp.E_!()` error instantiating -- |
April 04, 2022 [Issue 22981] Another forward reference bug involving a string mixin | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=22981 --- Comment #2 from Max Samukha <maxsamukha@gmail.com> --- > However, it does if the template instance is aliased inside the type: template E_() { mixin ("enum E_ {", S.attr, "}"); } struct S { alias E = E_!(); E e; enum attr = "a"; } -- |
April 04, 2022 [Issue 22981] Another forward reference bug involving a string mixin | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=22981 --- Comment #3 from Max Samukha <maxsamukha@gmail.com> --- (In reply to Max Samukha from comment #2) > > However, it does if the template instance is aliased inside the type: That wasn't supposed to be a quotation -- |
April 30, 2022 [Issue 22981] Another forward reference bug involving a string mixin | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=22981 Basile-z <b2.temp@gmx.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |b2.temp@gmx.com --- Comment #4 from Basile-z <b2.temp@gmx.com> --- I think that the compiler should perform a "pre-dsymbolsem" pass in aggregate decls, that pass would only target `enum` and other `static` declarations. That could kill the fake cycle on `E` and other similar bugs. -- |
April 30, 2022 [Issue 22981] Another forward reference bug involving a string mixin | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=22981 --- Comment #5 from Max Samukha <maxsamukha@gmail.com> --- (In reply to Basile-z from comment #4) > I think that the compiler should perform a "pre-dsymbolsem" pass in aggregate decls, that pass would only target `enum` and other `static` declarations. > > That could kill the fake cycle on `E` and other similar bugs. I am not competent to comment on this. FWIW, attributes, which are conceptually similar to static members, don't have this issue: mixin ("enum E {", __traits(getAttributes, S)[0], "}"); @("a") struct S { E e; } void main() { } -- |
April 30, 2022 [Issue 22981] Another forward reference bug involving a string mixin | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=22981 --- Comment #6 from Basile-z <b2.temp@gmx.com> --- (In reply to Max Samukha from comment #5) > I am not competent to comment on this. FWIW, attributes, which are conceptually similar to static members, don't have this issue: > > mixin ("enum E {", __traits(getAttributes, S)[0], "}"); > > @("a") > struct S > { > E e; > } > > void main() > { > } Nah, attribs have the same problem, it's just that your test case does not reproduce it. For attribs this is more like ``` mixin ("enum E {", __traits(getAttributes, S)[0], "}"); @(S.a) struct S { E e; enum a = "dfgdf"; } void main() { } ``` output is then the same as the original test case, i.e > Error: undefined identifier `E` -- |
April 30, 2022 [Issue 22981] Another forward reference bug involving a string mixin | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=22981 --- Comment #7 from Basile-z <b2.temp@gmx.com> --- In `S` the non static member `E e` create a cycle but actually with a pass dedicated to "static members - only" , the internal enum `S.a` would not require `S` semantic to be complete. -- |
April 30, 2022 [Issue 22981] Another forward reference bug involving a string mixin | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=22981 --- Comment #8 from Basile-z <b2.temp@gmx.com> --- (In reply to Basile-z from comment #7) > In `S` the non static member `E e` create a cycle but actually with a pass dedicated to "static members - only" , the internal enum `S.a` would not require `S` semantic to be complete. reduced more ``` @(S.a) struct S { E e; enum a = "dfgdf"; } ``` -- |
April 30, 2022 [Issue 22981] Another forward reference bug involving a string mixin | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=22981 --- Comment #9 from Basile-z <b2.temp@gmx.com> --- even better ``` enum E { e1 = S.a } struct S { E e; enum a = "string"; } ``` > /tmp/temp_7F3BFB9249F0.d:6:14: Error: cannot implicitly convert expression `"string"` of type `string` to `int` -- |
April 30, 2022 [Issue 22981] Another forward reference bug involving a string mixin | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=22981 --- Comment #10 from Basile-z <b2.temp@gmx.com> --- looks like enum being integral is assumed too early ;) for example if you change the infered type of S.a ``` enum E { e1 = S.a } struct S { E e; enum a = 123; // vs enum a = "string" } ``` no problems anymore -- |
Copyright © 1999-2021 by the D Language Foundation