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

use statement does not find renamed import #19799

Open
mppf opened this issue May 12, 2022 · 5 comments
Open

use statement does not find renamed import #19799

mppf opened this issue May 12, 2022 · 5 comments

Comments

@mppf
Copy link
Member

mppf commented May 12, 2022

I was expecting the following program to compile and run, because the use B brings in something named CC which actually refers to C; so use CC should work. However it does not.

module A {
  use B;
  use CC;

  var x = cvar;

  proc main() {
    writeln(x);
  }
}

module B {
  public import C as CC;
}

module C {
  var cvar: int = 1;
}
cc.chpl:3: error: Cannot find module or enum 'CC'

There is a variation that fails in a similar way but does not use an as statement:

module A {
  use B;
  use CC;

  var x = cvar;

  proc main() {
    writeln(x);
  }
}

module B {
  module C {
    module CC {
      var cvar: int = 1;
    }
  }

  public import this.C.CC;
}

This one also fails in a similar way with a public use instead:

module A {
  use B;
  use CC;

  var x = cvar;

  proc main() {
    writeln(x);
  }
}

module B {
  module C {
    module CC {
      var cvar: int = 1;
    }
  }

  public use C;
}
@mppf
Copy link
Member Author

mppf commented May 12, 2022

Here is a program doing a similar thing, but without an import that renames:

module A {
  use B;
  use CC;

  var x = cvar;

  proc main() {
    writeln(x);
  }
}

module B {
  module CC {
    var cvar: int = 1;
  }

  public import this.CC;
}

This one compiles and runs. But, the compiler here can just be using the module CC declaration itself and ignoring the public import.

@lydia-duncan
Copy link
Member

I kinda suspect these are two separate issues. My expectation is that the renaming one is a result of the use/import resolution diverging from scope and function resolution (and that a way of unifying those further would be a good idea).

The fact that it doesn't work for modules made visible by a public use or import without renaming is concerning and surprising, and I wonder if it failed in that way last release or if this is a result of recent changes (either your PR or some of my bug fixes during issues week)

@mppf
Copy link
Member Author

mppf commented May 12, 2022

All 3 examples in the OP fail with 1.26. (Also I don't think we necessarily need to fix this in the production compiler - we can just focus on getting it working in dyno).

@lydia-duncan
Copy link
Member

Also I don't think we necessarily need to fix this in the production compiler - we can just focus on getting it working in dyno

I'm definitely okay with that, especially since it seems like we're close to relying on that portion of the dyno compiler

@lydia-duncan
Copy link
Member

We should definitely file them as futures, though, so we don't forget that we want to fix them

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

2 participants