Simple test struct with a foreach and a static foreach outputting details at compile time
text/plain
647
Comments
Comment #0 by gooberman — 2018-05-07T13:22:45Z
Created attachment 1691
Simple test struct with a foreach and a static foreach outputting details at compile time
I have only tested this with two traits so far, but it does make generating automated bindings/equivalent objects inaccurate. At a minimum, the wrong __traits information gets returned from:
* identifier - returns the name of the static foreach iteration variable
* parent - returns the parent of said variable rather than the object type
Accessing the variables directly from object.tupleof[ index ] works just fine.
The attached test.d shows the issue.
Current output when compiling that file:
foreach pass:
foo has parent SomeStruct
bar has parent SomeStruct
anotherConst has parent SomeStruct
notAConst has parent SomeStruct
static foreach pass:
var has parent main()
bar has parent SomeStruct
var has parent main()
notAConst has parent SomeStruct
Expected output when compiling that file:
foreach pass:
foo has parent SomeStruct
bar has parent SomeStruct
anotherConst has parent SomeStruct
notAConst has parent SomeStruct
static foreach pass:
foo has parent SomeStruct
bar has parent SomeStruct
anotherConst has parent SomeStruct
notAConst has parent SomeStruct
Comment #1 by razvan.nitu1305 — 2023-05-05T09:50:28Z
I cannot reproduce this. With latest master I get:
foreach pass:
foo has parent SomeStruct
bar has parent SomeStruct
anotherConst has parent SomeStruct
notAConst has parent SomeStruct
static foreach pass:
foo has parent SomeStruct
bar has parent SomeStruct
anotherConst has parent SomeStruct
notAConst has parent SomeStruct
which is the correct result.