https://issues.dlang.org/show_bug.cgi?id=20237

          Issue ID: 20237
           Summary: with gagged errors from is(typeof()), compiler forgets
                    that it failed to compile a method
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: [email protected]
          Reporter: [email protected]

Consider the following code:

https://run.dlang.io/is/pXwdyp:

struct Struct()
{
    void method()
    {
        static assert(false);
    }
}

static Struct!() foo()()
{
    return Struct!().init;
}

enum b = is(typeof(foo().method()));

void main() { foo().method(); }

Clearly, this code should not compile. At the latest, `main` should error out
because `foo` is clearly not a valid function. However, this code hits a
*linker error* instead - the frontend lets it through it with zero complaints.

It seems plausible that since `foo` is only evaluated once per parameters, and
`foo` is first instantiated while in the gagged `is(typeof())` context, the
struct is instantiated successfully despite missing a method.

--

Reply via email to