Thread overview
[Issue 23945] ICE caused by std.sumtype
May 30, 2023
Basile-z
May 30, 2023
FeepingCreature
May 30, 2023
FeepingCreature
May 30, 2023
https://issues.dlang.org/show_bug.cgi?id=23945

Basile-z <b2.temp@gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice
                 CC|                            |b2.temp@gmx.com
           Severity|blocker                     |critical

--
May 30, 2023
https://issues.dlang.org/show_bug.cgi?id=23945

FeepingCreature <default_357-line@yahoo.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |default_357-line@yahoo.de

--- Comment #1 from FeepingCreature <default_357-line@yahoo.de> ---
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...

--
May 30, 2023
https://issues.dlang.org/show_bug.cgi?id=23945

--- Comment #2 from FeepingCreature <default_357-line@yahoo.de> ---
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.

--