[Issue 20237] New: with gagged errors from is(typeof()), compiler forgets that it failed to compile a method
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Sep 23 16:28:29 UTC 2019
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: nobody at puremagic.com
Reporter: default_357-line at yahoo.de
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.
--
More information about the Digitalmars-d-bugs
mailing list