http://d.puremagic.com/issues/show_bug.cgi?id=3452
Maxim Fomin <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |[email protected] --- Comment #3 from Maxim Fomin <[email protected]> 2013-08-06 10:12:00 PDT --- (In reply to comment #0) > struct Foo { > void bar() {} > void baz() {} > } > > void doStuff(Foo foo) { > alias foo.bar fun; > fun(); // Error: need 'this' to access member bar > } > Actually error message is reasonable for the same reason as Foo.bar requires this pointer. The root of the issue is that alias does not capture local variable in this context - it captures only type name. The code above is essentially alias Foo.bar fun and since bar() is nonstatic the code doesn't compile. > I can't think of any reason why this shouldn't work. foo.bar is a > compile-time > symbol for the member function Foo.bar() on the instance foo. Once I alias > foo.bar to fun, calling fun() should be equivalent to calling foo.bar(). Because of underspecification many view things different to what compiler does. > Even if there's some language legalese reason why this shouldn't work > according > to the spec, it's still a reasonable enhancement request. Yes, but this isn't a minor enhancement. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
