[Issue 22497] Spurious dual-context error

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Nov 10 19:15:38 UTC 2021


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

--- Comment #3 from kinke <kinke at gmx.net> ---
(In reply to Andrei Alexandrescu from comment #2)
> Not sure I understand but hopefully it's something that can be fixed, right?

Nevermind, that's what the compiler does for a freestanding function template.
In your example with parent template instance, the current behavior seems to
match that of a simple struct parent:

```
int foo(alias f)(int x) { return f(x); }

struct S {
    static int staticFoo(alias f)(int x) { return f(x); }
    int foo(alias f)(int x) { return f(x); }
}

void main() {
    int x = 42;
    int nested(int y) { return y + x; }
    foo!nested(1);
    // should work analogously (without dual context) but doesn't:
    //S.staticFoo!nested(1);
    // correctly requires dual-context:
    S().foo!nested(1);
}
```

So some logic seems to be definitely off here (and surely fixable).

--


More information about the Digitalmars-d-bugs mailing list