Repository navigation
Conversation
|
If I understand the issue correctly, then yes, it is expected. |
|
Oh right, I forgot that part.. yes, then because of recursive types I think we do need this, marking as non-draft. |
| // will end up with a type that does not compare equally. | ||
| return true; | ||
| } | ||
| if (a.type != b.type) { |
There was a problem hiding this comment.
An alternative would be to not special-case ref types, but to change the condition to a.type != b.type && (a.type < b.type || b.type < a.type), which will detect structurally equivalent types correctly.
There was a problem hiding this comment.
But would that work with recursive types, for which we create a new one when roundtripping which is the issue here?
There was a problem hiding this comment.
Yes. operator< compares structure, not identity. (The bug it has where it can compare two types as mutually less than each other should not affect this use case.)
There was a problem hiding this comment.
Oh right, the problem is just of comparing equality via identity... changed as you suggested.
|
Ah, as CI shows that does not work actually. The two types are not identical to each other after roundtripping. So the problem is still there. Is it not as I thought earlier, that roundtripping creating new versions of recursive types is a problem for subtype checks between them later? If that's not it I guess I'll need to debug the comparison code unless you have an idea. |
|
The new types should be structurally identical to the old types and therefore the new and old types should be subtypes of each other (and Type::isSubType should reflect that). If they are not structurally identical after round tripping, that sounds like a bug. |
|
What happens appears to be this:
All that makes sense. Then Signature checking for subTyping does this: // TODO: Implement proper signature subtyping, covariant in results and
// contravariant in params, once V8 implements it.
// return isSubType(b.params, a.params) && isSubType(a.results, b.results);
return a == b;Do you remember why we commented that out? Looks like you added it in #3610 |
|
(Even if v8 doesn't have it yet, I think we should maybe uncomment it - hard for me to see the danger the commenting implies.) |
|
Aha, that will do it! Using |
|
Actually, I think the subtyper could be changed to use |
|
Why would It seems simpler to just not compare reference types at all here as in the first version of this PR? Or, what is the benefit of using |
|
Yes, it's an arbitrary order, but it is a total order on structural types, so it can be used to detect structural equality. This will be moot once I update == to use structural equality (which I plan to do by the end of Monday). |
The testcase here passes with
--fuzz-execbut fails when adding--roundtrip,as then the type appears different. Is that expected @tlively ?