-
Notifications
You must be signed in to change notification settings - Fork 797
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
Enforce union case declarations AttributeTargets #16764
Changes from 13 commits
54b00ab
eb37d50
fbcedc4
e3d7c8f
4670669
75ef665
bdd617f
b478166
965f3b3
f53381e
50e2f28
c79162c
5b4c13b
7fe37a1
8ce9d7b
80cbd2a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// This tests that AttributeTargets.Field is not allowed in union-case declaration | ||
|
||
open System | ||
|
||
[<AttributeUsage(AttributeTargets.Field)>] | ||
type FieldLevelAttribute() = | ||
inherit Attribute() | ||
|
||
[<AttributeUsage(AttributeTargets.Property ||| AttributeTargets.Field)>] | ||
type PropertyOrFieldLevelAttribute() = | ||
inherit Attribute() | ||
|
||
type SomeUnion = | ||
| [<FieldLevel>] Case1 of int // Should fail | ||
| [<PropertyOrFieldLevel>] Case2 of int // Should fail | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// This tests that AttributeTargets.Property is not allowed in union-case declaration | ||
|
||
open System | ||
|
||
[<AttributeUsage(AttributeTargets.Property)>] | ||
type PropertyLevelAttribute() = | ||
inherit Attribute() | ||
|
||
[<AttributeUsage(AttributeTargets.Property ||| AttributeTargets.Field)>] | ||
type PropertyOrFieldLevelAttribute() = | ||
inherit Attribute() | ||
|
||
type SomeUnion = | ||
| [<PropertyLevel>] Case1 of int // Should fail | ||
| [<PropertyOrFieldLevel>] Case2 of int // Should fail |
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.
Following the logic from IlxGen, this should branch on arguments for the case.
Case with no data is a property.
Case with fields is a method.
There are other concerns affecting DU IL generation (structness, null as true value, number of cases), but so far I have not found any other affecting case-level attribute placement beyond what I wrote above (and what Eugene pointed out).
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.
Thanks for the review. See #16807
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.
If you find any other case. Let me know, I really want to improve this area of the compiler