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.
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
Extend
PartialStruct
to represent non-contiguously defined fields #57304base: master
Are you sure you want to change the base?
Extend
PartialStruct
to represent non-contiguously defined fields #57304Changes from 16 commits
b25a8a7
67b12f8
58827f0
1274f23
ede6dc7
f361ab2
201c956
67b9168
3857baf
00b1135
c9ee9b0
ced6296
c6e7099
b44dfb5
a272011
02746fa
b1efbe5
741b52f
7309506
5947f49
d771b94
b20cf69
32d3a89
feda5d2
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Hmm, this looks a bit strange even before this PR. Does this take into account
isdefined(a.val, i)
properly?If the
Const
has all-undefined fields, wouldn't that be declared⊑ PartialStruct(..., [Const(1),Const(2)])
?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 would consider that
Const($(Expr(:new, T)))
andConst($(Expr(:new, T, a, b)))
for example encode different values, without one being more specific than the other. It's known-undef vs known-def, in the case that it would have been maybe-undef vs known-def I guess the latter would have indeed been⊑
to the former.EDIT: seems like the
isdefined(a.val, i) || continue
expression two lines above does consider the firstConst
to be⊑
to the second, and re-reading what you said you seem to be in agreement with the line you commented at. Am I missing something?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.
The current implementation seems fine. This is because the information about field defined-ness obtained from
a::Const
is always more accurate. In other words, when it comes to field defined-ness, the order is always guaranteed to bea ≤ b
. So, if we have information about thei
-th field type froma
but not fromb
, the order will never beaᵢ > bᵢ
.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.
That's not obvious to me - Can you explain more?
The two problems I see are:
Const
fields may not match fields inPartialStruct
type, which is a soundness issueundef[i] && fields[i] === Union{}
is equivalent to an undef field in theConst
, which is a completeness issueAs an example of (1) notice that
Foo(#undef, #undef) isa Const(Foo(#undef, #undef))
but it's not true that the same objectisa PartialStruct(Foo, undef=[false,false], fields=[Const(1),Const(2)])
, which means we have to returnfalse
for⊑
between these types for soundness.