digitalmars.D.learn - Circular enum member references in UDAs
- realhet (30/30) Feb 15 2024 Hello,
- Paul Backus (5/17) Feb 15 2024 Looks like someone reported a similar bug in 2018:
- realhet (6/9) Feb 15 2024 That means I will solve this by putting the UDAs into a separate
Hello,
Today I tried to upgrade my sources to the latest LDC, but failed
with this unfortunate error.
```
import std;
struct S{ E e; }
enum E
{
S(e2) e1,
S(e1) e2
}
void main() {
E.e1.writeln;
}
```
It only runs in DMD 2.086.1 to 2.101.2
I can only think that the compiler changed from two pass lazy
interpretation down to a single pass. So when it finds the very
first attribute " S(e2)" it immediately wants to lookup the
member e2 and fails.
I really liked this feature because it was so compact. I was able
to define a state-graph used to parse the structure of almost any
DLang source files.
This way the structure of the D language can be defined on 1 page
in D language itself.
[https://ibb.co/HFWR2Qg](https://ibb.co/HFWR2Qg)
Is there a better practice to do this? All else I can think of
that the graph-nodes and the graph-edges are declared separately,
that would be more redundant. This self-referencing way was the
only way to declare them in-place.
Feb 15 2024
On Thursday, 15 February 2024 at 18:12:42 UTC, realhet wrote:
Hello,
Today I tried to upgrade my sources to the latest LDC, but
failed with this unfortunate error.
```
import std;
struct S{ E e; }
enum E
{
S(e2) e1,
S(e1) e2
}
```
Looks like someone reported a similar bug in 2018:
https://issues.dlang.org/show_bug.cgi?id=17656
There was an attempt to fix it, but it looks like the PR author
wasn't able to get it working correctly in all cases.
Feb 15 2024
On Thursday, 15 February 2024 at 20:10:15 UTC, Paul Backus wrote:On Thursday, 15 February 2024 at 18:12:42 UTC, realhet wrote: There was an attempt to fix it, but it looks like the PR author wasn't able to get it working correctly in all cases.That means I will solve this by putting the UDAs into a separate array. With a mixin I can still do it without extra redundancy, while the compiler enforce the logical correctness of the identifiers. Thank You for the info.
Feb 15 2024








realhet <real_het hotmail.com>