Bug 20237 – with gagged errors from is(typeof()), compiler forgets that it failed to compile a method
Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2019-09-23T16:28:29Z
Last change time
2023-04-18T09:49:17Z
Keywords
accepts-invalid
Assigned to
No Owner
Creator
FeepingCreature
Comments
Comment #0 by default_357-line — 2019-09-23T16:28:29Z
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.
Comment #1 by razvan.nitu1305 — 2023-04-18T09:49:17Z
This is a dupe of 15459.
*** This issue has been marked as a duplicate of issue 15459 ***