Skip to content

Conversation

@dsyme
Copy link
Contributor

@dsyme dsyme commented Aug 9, 2022

Fixes #13607

The problem is if the type test on the struct succeeds, but the condition fails, then later type tests for related interfaces are assumed to fail.

This is actually noted as a case of concern in the comment but there was not a matching test for it, which shows that my testing for this change was inadequate - it should have at least covered every case identified in the comments.

Some baselines may need updating

@vzarytovskii vzarytovskii merged commit 9007c43 into dotnet:main Aug 9, 2022
Copy link
Contributor Author

@dsyme dsyme left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vzarytovskii more ideas for tests noted

[<InlineData("DateTime", "DateTime.Now")>]
[<InlineData("int", "1")>]
[<InlineData("Guid", "(Guid.NewGuid())")>]
[<InlineData("Byte", "0x1")>]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Byte-typed literals are 1uy. Curious this compiles and passes. I guess the object is an integer and the first type test fails but the second still succeeds.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should test this kind of logic when testing array types. Particularly signed/unsigned integer arrays which have strange rules in .net (int32[] can runtime-coerce to unit32[]) . Likewise arrays of enums. Also covariant coercions for reference array types.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Byte-typed literals are 1uy. Curious this compiles and passes. I guess the object is an integer and the first type test fails but the second still succeeds.

Sigh, yeah, I fixed it locally but didn't push. Well, obj is bad :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Invalid branch code generation of type tests in VS 17.2.6

3 participants