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

Weird problem when passing borrowed C as type argument #15586

Closed
dlongnecke-cray opened this issue Apr 24, 2020 · 1 comment · Fixed by #16380
Closed

Weird problem when passing borrowed C as type argument #15586

dlongnecke-cray opened this issue Apr 24, 2020 · 1 comment · Fixed by #16380
Assignees
Milestone

Comments

@dlongnecke-cray
Copy link
Contributor

Summary of Problem

When I pass the type borrowed C to a function and then instantiate the type argument using new, I expect an instance of a borrowed C but get an owned C.

Steps to Reproduce

Source Code:

class C { var x: int = 0; }

proc test(type t) {
  var x = new t(128);
  compilerWarning(x.type:string);
  return;
}
type t = borrowed C?;
test(t);
@dlongnecke-cray
Copy link
Contributor Author

Discussion about this started in #15394.

Here's a copy of a post I made there earlier...


It's clear that the decorator is there and then is being ignored, though...

class C { var x: int = 0; }

proc test(type t) {
  var x = new borrowed t(128);
  compilerWarning(x.type:string);
  return;
}
type T = borrowed C?;
test(T);
TestPassedBorrow.chpl:3: In function 'test':
TestPassedBorrow.chpl:4: error: duplicate decorators - borrowed borrowed C?
TestPassedBorrow.chpl:9: Function 'test' instantiated as: test(type t = borrowed C?)
TestPassedBorrow.chpl:9: warning: borrowed C?

If the class didn't have a decorator attached to it I would expect an implicit owned. But when it already has a borrowed, seems weird to just discard it.

@mppf mppf self-assigned this Sep 8, 2020
@bradcray bradcray added this to the PB Sprint 54 milestone Sep 8, 2020
mppf added a commit to mppf/chapel that referenced this issue Sep 14, 2020
mppf added a commit that referenced this issue Sep 14, 2020
Fix problem with new applied to a borrowed nilable type argument

Resolves #15586

Reviewed by @dlongnecke-cray - thanks!

- [x] full local futures testing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants