Bug 23945 – ICE caused by std.sumtype

Status
NEW
Severity
critical
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2023-05-30T09:02:06Z
Last change time
2024-12-13T19:29:19Z
Keywords
ice
Assigned to
No Owner
Creator
yusharora
Moved to GitHub: dmd#20289 →

Comments

Comment #0 by yusharora — 2023-05-30T09:02:06Z
See dlang forum thread: https://forum.dlang.org/post/[email protected] Source: https://gist.github.com/run-dlang/5dd783c750f04329405af1b1e4a83cde ```d Error: unknown, please file report on issues.dlang.org /usr/include/dlang/dmd/std/meta.d(632,42): Error: template instance `std.sumtype.matchImpl!(Flag.yes, destroyIfOwner).matchImpl!(SumType!(ConstValueIndex, EnumConstValue, ClassInfoIndex, AnnotationValue, ArrayValue)).matchImpl.valueTypes!4LU.fun!0LU` error instantiating /usr/include/dlang/dmd/std/sumtype.d(1931,32): instantiated from here: `Map!(getType, 0LU)` /usr/include/dlang/dmd/std/sumtype.d(1967,51): instantiated from here: `valueTypes!4LU` /usr/include/dlang/dmd/std/sumtype.d(1649,52): instantiated from here: `matchImpl!(SumType!(ConstValueIndex, EnumConstValue, ClassInfoIndex, AnnotationValue, ArrayValue))` /usr/include/dlang/dmd/std/sumtype.d(752,17): instantiated from here: `match!(SumType!(ConstValueIndex, EnumConstValue, ClassInfoIndex, AnnotationValue, ArrayValue))` source/parser/definitions/attributes.d(262,22): instantiated from here: `SumType!(ConstValueIndex, EnumConstValue, ClassInfoIndex, AnnotationValue, ArrayValue)` /usr/include/dlang/dmd/std/sumtype.d(1985,13): while evaluating: `static assert((__error)(hid))` Error /usr/bin/dmd failed with exit code 1. ```
Comment #1 by default_357-line — 2023-05-30T12:12:55Z
Maybe reduction: struct SumType() { ArrayValue value; this(ArrayValue value) { this.value = value; } static if (__traits(compiles, hashOf(ElementValuePair.init))) { size_t toHash() { return 0; } } } struct ArrayValue { ElementValue[] values; } struct ElementValuePair { ElementValue element_value; } alias ElementValue = SumType!(); ==== Error: unknown, please file report on issues.dlang.org I suspect something with hashOf and struct initialization order. I think this may have been a few steps minified too far, but it's still spitting out "Error: unknown", so...
Comment #2 by default_357-line — 2023-05-30T12:29:26Z
As a workaround, sticking this code into AnnotationValue in the original code: size_t toHash() const { return hashOf(annotation_value); } also makes it compile. I think because the hashOf is hidden in a method body, the sema doesn't have to recurse immediately from AnnotationValue into Annotation, which breaks the loop.
Comment #3 by robert.schadek — 2024-12-13T19:29:19Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/20289 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB