digitalmars.D.bugs - [Issue 18840] New: static foreach over an object's tupleof gives
- d-bugmail puremagic.com (48/48) May 07 2018 https://issues.dlang.org/show_bug.cgi?id=18840
https://issues.dlang.org/show_bug.cgi?id=18840 Issue ID: 18840 Summary: static foreach over an object's tupleof gives wrong information for const variables Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: major Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: gooberman gmail.com Created attachment 1691 --> https://issues.dlang.org/attachment.cgi?id=1691&action=edit 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 --
May 07 2018