Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: problem compiling implicit this. in nested method #26088

Open
mppf opened this issue Oct 15, 2024 · 0 comments
Open

[Bug]: problem compiling implicit this. in nested method #26088

mppf opened this issue Oct 15, 2024 · 0 comments

Comments

@mppf
Copy link
Member

mppf commented Oct 15, 2024

Summary of Problem

Description:
The language allows nested functions and methods, and also allows field access with implicit this.. However, the combination of these is not working.

At present, it looks like the dyno resolver / scope resolver is handling this correctly, but some later stage of compilation is not handling this pattern.

Is this issue currently blocking your progress?
No, I came across this issue when working on PR #25878.

Steps to Reproduce

Source Code:

module DefinesX {
  record X {
    var field: real;
    var x: real;
  }
}

module DefinesY {
  record Y {
    var field: int;
    var y: int;
  }
}

module Main {
  use DefinesX;
  use DefinesY;

  proc X.outer() {
    proc Y.inner() {
      x;     // should refer to X.x, via the outer method
      field; // should refer to Y.field, via the inner method
    }
    (new Y()).inner(); // call inner() to make sure it is resolved

    x; // should refer to X.x
    //y; // should not resolve
    field; // should refer to X.field
  }

  proc main() {
    (new X()).outer(); // call outer() to make sure it is resolved
  }
}
chpl --no-devel nested-method-implicit-field-access.chpl
nested-method-implicit-field-access.chpl:19: In method 'outer':
nested-method-implicit-field-access.chpl:21: error: unresolved call 'Y.x'
nested-method-implicit-field-access.chpl:4: note: this candidate did not match: X.x
nested-method-implicit-field-access.chpl:21: note: because method call receiver with type 'Y'
nested-method-implicit-field-access.chpl:4: note: is passed to formal 'ref this: X'

In Chapel 2.1 the error was different:

nested-method-implicit-field-access.chpl:21: error: Illegal use of identifier 'x' from enclosing type
Note: This source location is a guess.

Associated Future Test(s):
test/classes/methods/nested-method-implicit-field-access.chpl #26089

@mppf mppf added the type: Bug label Oct 15, 2024
mppf added a commit that referenced this issue Oct 15, 2024
This PR adds a .future test for issue #26088.

Test change only - not reviewed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant