Bug 8217 – static nested class can reference outer scope by template instantiation
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-06-10T13:39:00Z
Last change time
2015-06-17T21:04:03Z
Keywords
accepts-invalid
Assigned to
nobody
Creator
timon.gehr
Comments
Comment #0 by timon.gehr — 2012-06-10T13:39:50Z
class D{
int x;
template bar(){
int foo(){
return x;
}
}
static class C{
int foo(){
return bar!().foo();
}
}
}
C does not have a reference to the enclosing context, therefore the call to bar!().foo is invalid.
DMD 2.059 accepts the code.
Comment #1 by hsteoh — 2014-08-18T17:21:55Z
With dmd git HEAD (2.067a):
-----
test.d(10): Error: this for foo needs to be type D not type test.D.C
-----
Should this bug be closed now?
Comment #2 by k.hara.pg — 2015-03-03T04:09:15Z
(In reply to hsteoh from comment #1)
> With dmd git HEAD (2.067a):
> -----
> test.d(10): Error: this for foo needs to be type D not type test.D.C
> -----
>
> Should this bug be closed now?
Seems to be fixed from 2.063.
Comment #3 by github-bugzilla — 2015-04-02T13:14:30Z