Bug 16215 – Nested class unable to resolve outer class variables in certain scenarios

Status
NEW
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2016-06-28T01:08:02Z
Last change time
2024-12-13T18:48:41Z
Keywords
pull, rejects-valid
Assigned to
No Owner
Creator
Puneet Goel
Moved to GitHub: dmd#17763 →

Comments

Comment #0 by puneet — 2016-06-28T01:08:02Z
This is one of the corner cases that I could reduce. bool frop(int f) {return true;} class Bar { int zoo; class Foo { bool foo() { return (zoo).frop(); } } } $ dmd -c test.d test.d(6): Error: need 'this' for 'zoo' of type 'int'
Comment #1 by puneet — 2016-06-29T02:17:13Z
Another reduced case: class Foo { class FooInner {} } class Bar: Foo { byte foo; class BarInner(T): Foo.FooInner { byte zoo() { return foo; } } alias BarInnerThis = BarInner!Bar; } $ dmd -c test.d test.d(8): Error: need 'this' for 'foo' of type 'byte'
Comment #2 by ismailsiege — 2019-05-07T19:22:46Z
Analogous case that does not work in dmd 2.086.0, but works in 2.085.0: class Base { class BaseInner {} } final class Derived: Base { bool someMethod() { return false; } final class DerivedInner: BaseInner { void func() { pragma(msg, typeof(this.outer)); // prints "Derived" someMethod(); } } } void main() {} compiler output: Derived onlineapp.d(17): Error: this for someMethod needs to be type Derived not type onlineapp.Base
Comment #3 by er.krali — 2019-06-17T08:31:45Z
Shouldn't this bug be marked now as a regression? Checking the code in the previous comment: Up to 2.067.1: Success with output: Base 2.068.2 to 2.085.1: Success with output: Derived Since 2.086.0: Failure with output: ----- Derived onlineapp.d(16): Error: `this` for `someMethod` needs to be type `Derived` not type `onlineapp.Base` -----
Comment #4 by bugzilla — 2020-02-13T08:40:11Z
(In reply to Puneet Goel from comment #0) > This is one of the corner cases that I could reduce. - return (zoo).frop(); + return frop(zoo); Note with the above change it compiles successfully.
Comment #5 by bugzilla — 2020-02-13T09:02:43Z
These actually appear to be three separate issues.
Comment #6 by razvan.nitu1305 — 2021-02-24T13:08:42Z
(In reply to Walter Bright from comment #4) > (In reply to Puneet Goel from comment #0) > > This is one of the corner cases that I could reduce. > > - return (zoo).frop(); > + return frop(zoo); > > Note with the above change it compiles successfully. That specific case seems to be running fine with today's compiler.
Comment #7 by dlang-bot — 2021-10-28T15:07:25Z
@RazvanN7 created dlang/dmd pull request #13236 "Fix Issue 16215 - Nested class unable to resolve outer class variables in certain scenarios" fixing this issue: - Fix Issue 16215 https://github.com/dlang/dmd/pull/13236
Comment #8 by robert.schadek — 2024-12-13T18:48:41Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/17763 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB