-
Notifications
You must be signed in to change notification settings - Fork 64
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
Fix justActive condition #1936
Merged
+12
−1
Merged
Fix justActive condition #1936
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I understand the failure but I’m confused why this would resolve it.
@vchuravy do you have cycles to review as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned in #1935 (comment), the problem is that a struct that contains non-isbits fields and can be incompletely initialized will not be allocated inline, even if it is immutable. As such, it's an error to conclude anything about activity from
allocatedinline
. A type can have immutable semantics and thus contain active values even if it is not allocated inline.A mutable type, however, is of either duplicated or const type, hence it's safe to take this early return path. (Judging by #1926 this is true even if the mutable type has differentiable const fields.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose since a non-inlined value necessarily has a memory address, an alternative would be to disregard the purported immutability and let
make_zero!
zero out the relevant fields anyway. However, theccall(:jl_set_nth_field, ...)
solution from #1926 doesn't work on these types, so it would have to be done with raw pointer twiddling.But this doesn't sound appealing to me for several reasons, the most important of which is that you can now get a DupState type by nesting an immutable ActiveState type inside an immutable container (provided the
justActive = false
case is changed to be consistent with this choice). SeeTuple{Incomplete}
from the test case for an example; in other words, this would require a user to annotate anIncomplete
argument asActive
orMixedDuplicated
, but aTuple{Incomplete}
argument asDuplicated
. This would be non-intuitive, hard to reason about, and probably even harder to explain to users. Better to respect thatIncomplete
is immutable as declared. That leaves us with the above conclusion: you can't useallocatedinline
to conclude about activity state.