Thread overview
[Issue 19990] unknown error with missing import
Nov 04, 2019
Basile-z
Mar 21, 2020
Basile-z
Dec 17, 2022
Iain Buclaw
June 21, 2019
https://issues.dlang.org/show_bug.cgi?id=19990

elpenguino+D@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice-on-invalid-code

--
August 10, 2019
https://issues.dlang.org/show_bug.cgi?id=19990

elpenguino+D@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|ice-on-invalid-code         |ice

--
November 04, 2019
https://issues.dlang.org/show_bug.cgi?id=19990

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |b2.temp@gmx.com

--- Comment #1 from Basile-z <b2.temp@gmx.com> ---
The real error from a.d should be

"Error: template instance Nullable!bool template Nullable is not defined"

but it leaks for some reason. I can recover it by patching Nullable opEquals. Its constraint in combination with the template mess of std.format seems to be the cause of this nightmarish ICE.

I've managed to reduce a bit, so the test case becomes:

a.d:
```
module a;

struct A {
        import b : B;
        Nullable!bool z;
}
```
b.d:
```
module b;

import c : Nullable;

struct B {
        import a : A;
        A[] a;
}

Nullable!B b() {
        return Nullable!B.init;
}
```
c.d:
```
module c;

import std.format;

struct Nullable(T)
{
    private T _value;

    private bool _isNull = true;

    import std.traits : ReturnType;

    version(OK)
    {
        bool opEquals(U)(auto ref const(U) rhs) const
        if (is(ReturnType!(get) == rhs)) // OK, good error does not leak
        {
            return _isNull ? false : rhs == _value;
        }
    }
    else
        bool opEquals(U)(auto ref const(U) rhs) const
        if (is(typeof(get == rhs)))         // NG
        {
            return _isNull ? false : rhs == _value;
        }

    string toString()
    {
        import std.array : appender;
        auto app = appender!string();
        auto spec = singleSpecLocal("%s");
        toString(app, spec);
        return app.data;
    }

    void toString(W)(ref W writer, scope const ref FormatSpec!char fmt)
    {
        formatValue(writer, _value, fmt);
    }

    @property ref inout(T) get() inout @safe pure nothrow
    {
        return _value;
    }

    alias get this;
}

FormatSpec!Char singleSpecLocal(Char)(Char[] fmt)
{
    return FormatSpec!Char .init;
}

```

compiles with dmd a.b b.d c.d to reproduce the ICE
compiles with dmd a.b b.d c.d -version=OK to see the standard, expected failure

Now it's hard to say if phobos Nullable should be fixed or if more investigation will reveal a DMD bug. I think there's definitively one but the test case is still not ideal.

--
March 21, 2020
https://issues.dlang.org/show_bug.cgi?id=19990

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|b2.temp@gmx.com             |

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=19990

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P3

--