Skip to content
New issue

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

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

Already on GitHub? # to your account

errors with promotion and non-nilable owned #14941

Open
mppf opened this issue Feb 20, 2020 · 3 comments
Open

errors with promotion and non-nilable owned #14941

mppf opened this issue Feb 20, 2020 · 3 comments

Comments

@mppf
Copy link
Member

mppf commented Feb 20, 2020

I would expect both of the following programs to function but the result in errors after PR #14835. They produce different errors.

class C {
  var x: int;
}
  
record R {
  var x;
  proc init() {
    x = new owned C(1..10);
  }
}

proc main() {
  var r = new R();
  writeln(r);
}
class C {
  var x: int;
}

record R {
  var x: [1..10] owned C;
  proc init() {
    x = new owned C(1..10);
  }
}

proc main() {
  var r = new R();
  writeln(r);
}
@mppf
Copy link
Member Author

mppf commented Feb 20, 2020

When this issue is resolved, workaround changes to test/studies/shootout/chameneos-redux/elliot/chameneosredux-ejr.chpl should be removed.

mppf added a commit to mppf/chapel that referenced this issue Feb 20, 2020
mppf added a commit to mppf/chapel that referenced this issue Feb 21, 2020
mppf added a commit that referenced this issue Feb 24, 2020
Errors for ownership transfer from non-nilable owned

Resolves #13600.

This PR adds compilation errors for ownership transfer from non-nilable owned.

* Adjusts setInstantiationPoint to avoid resetting
  userInstantiationPointLoc when clearing the instantiation point in
  cleanups
* Adds `FLAG_IGNORE_TRANSFER_ERRORS` to disable the new errors  on a
  per-function basis and mark two array implementation functions with
  these
* In checkForErroneousInitCopies, mark functions only called in erroneous
  copy functions with `FLAG_ERRONEOUS_COPY` so we can avoid raising
  transfer errors in them
* Adds findNonNilableStoringNil, an analysis called in callDestructors
  and stored in nilChecking. This analysis raises an error for ownership
  transfer from non-nilable owned except in certain cases. It currently
  is connected to the expiring value analysis (following #13704) but we
  may make it stricter.
* Fixes findCopyInitFn and findAssignFn for tuples
* mark `init=` with `FLAG_ERRONEOUS_COPY` along with initCopy etc in
  resolution if it contains an error
* in errorIfNonNilableType, don't raise errors for variables declared
  with `FLAG_NO_INIT`
* in findLocationIgnoringInternalInlining, avoid an infinite loop if no
  calls were found to a function
* change several TaskErrors methods to return/yield `owned Error?`
  instead of other types in order to allow the user to throw one of these
  without generating an ownership transfer error.
* in SharedObject, factor clear logic into new method `doClear` so that
  `clear` can be more aggressively checked than deinit.
* Add errors in `list` for copy-initialization from types that cannot be
  copied.
* Adjust `list.pop` to move from the list into the return value rather
  than copying. This allows `list.pop` to be used on a list storing
  non-nilable owned.
* Adjust quite a few tests to avoid the new errors.

- [x] full local testing

Reviewed by @benharsh - thanks!

Future work: issues #14942 #14941 #14940
@cassella
Copy link
Contributor

The second example compiles and runs for me with #14835, at least as of 0a7f2d4

@cassella
Copy link
Contributor

Both examples compile and run for me, and are clean under --memLeaks.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants