-
Notifications
You must be signed in to change notification settings - Fork 847
Fix [<RequireQualifiedAccess>] on a DU shadows types in the same module #1512
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
1f992d5
Reproduce #1253
forki e94d90d
Union resolution should not stop other searches
forki dceea0c
reproduce #1294
forki c92208e
fix #1294
forki d9402ee
Show that constructor syntax still works
forki fd1c06c
Fix shortcut
forki 5adfc1f
Fix shortcut
forki 21c94b7
Adding further tests
forki a48463d
Search for a discriminated union without RequireQualifiedAccess attri…
forki aa7eacb
Don't run union search twice
forki 0127d85
Simplify code
forki 318b41d
Fix encoding issue
forki 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 hidden or 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
11 changes: 11 additions & 0 deletions
11
.../Conformance/InferenceProcedures/NameResolution/RequireQualifiedAccess/OnRecordVsUnion.fs
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| // #Conformance #TypeInference #Attributes | ||
| // Verify the RequireQualifiedAccess attribute works on unions | ||
|
|
||
| module A = | ||
| [<RequireQualifiedAccess>] | ||
| type U = | C | ||
|
|
||
| type C() = | ||
| static member M() = () | ||
|
|
||
| let x = A.C.M() | ||
19 changes: 19 additions & 0 deletions
19
...Conformance/InferenceProcedures/NameResolution/RequireQualifiedAccess/OnRecordVsUnion2.fs
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| // #Conformance #TypeInference #Attributes | ||
|
|
||
| module Module = | ||
| type R = { a: int } with static member New = { a = 1 } | ||
| type Choice = | R of R | ||
| open Module | ||
|
|
||
| let record1 = R.New | ||
| let choice1 v = | ||
| match v with | ||
| | R r -> r | ||
|
|
||
| let newChoice = R { a = 1} | ||
|
|
||
| let choice2 v = | ||
| match v with | ||
| | Module.R r -> r | ||
|
|
||
| let newChoice2 = Module.R { a = 1} |
10 changes: 10 additions & 0 deletions
10
...rmance/InferenceProcedures/NameResolution/RequireQualifiedAccess/OnRecordVsUnion_NoRQA.fs
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| // #Conformance #TypeInference #Attributes | ||
| // Verify the access works on unions without RQA | ||
|
|
||
| module A = | ||
| type U = | C | ||
|
|
||
| type C() = | ||
| static member M() = () | ||
|
|
||
| let x:A.U = A.C |
10 changes: 10 additions & 0 deletions
10
...mance/InferenceProcedures/NameResolution/RequireQualifiedAccess/OnRecordVsUnion_NoRQA2.fs
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| // #Conformance #TypeInference #Attributes | ||
| // Verify the access works on unions without RQA | ||
|
|
||
| module A = | ||
| type U = | C | ||
|
|
||
| type C() = | ||
| static member M() = () | ||
|
|
||
| let x = A.C |
9 changes: 9 additions & 0 deletions
9
...ce/InferenceProcedures/NameResolution/RequireQualifiedAccess/OnUnionWithCaseOfSameName.fs
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| // #Conformance #TypeInference #Attributes | ||
| // Verify the access works on unions where type name is case name | ||
|
|
||
| module A = | ||
| type C = | ||
| | B | ||
| | C | ||
|
|
||
| let x = A.C |
10 changes: 10 additions & 0 deletions
10
...e/InferenceProcedures/NameResolution/RequireQualifiedAccess/OnUnionWithCaseOfSameName2.fs
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| // #Conformance #TypeInference #Attributes | ||
| // Verify the access works on unions where type name is case name | ||
|
|
||
| module A = | ||
| [<RequireQualifiedAccess>] | ||
| type C = | ||
| | B | ||
| | C | ||
|
|
||
| let x = A.C |
7 changes: 7 additions & 0 deletions
7
...rpqa/Source/Conformance/InferenceProcedures/NameResolution/RequireQualifiedAccess/env.lst
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,12 @@ | ||
| SOURCE=OnRecord.fs # OnRecord.fs | ||
| SOURCE=E_OnRecord.fs # E_OnRecord.fs | ||
|
|
||
| SOURCE=OnRecordVsUnion.fs # OnRecordVsUnion.fs | ||
| SOURCE=OnRecordVsUnion2.fs # OnRecordVsUnion2.fs | ||
| SOURCE=OnDiscriminatedUnion.fs # OnDiscriminatedUnion.fs | ||
| SOURCE=E_OnDiscriminatedUnion.fs # E_OnDiscriminatedUnion.fs | ||
|
|
||
| SOURCE=OnRecordVsUnion_NoRQA.fs # OnRecordVsUnion_NoRQA.fs | ||
| SOURCE=OnRecordVsUnion_NoRQA2.fs # OnRecordVsUnion_NoRQA2.fs | ||
| SOURCE=OnUnionWithCaseOfSameName.fs # OnUnionWithCaseOfSameName.fs | ||
| SOURCE=OnUnionWithCaseOfSameName2.fs # OnUnionWithCaseOfSameName2.fs |
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.
I'm trying to understand what this test adds. Today it gives a warning and then doesn't compile. What does it give after this PR? Does it just compile?
Likewise, what happens after this PR without the RQA attribute (and with the last line adjusted to
let x : A.C = A.C)? Today that compiles without warning? But it feels to me that after this change then it won't compile any more? I haven't tried yet, just wondering.Adding these test cases would be good, and also adding test cases for union types where the type name is the same as the union case name, e.g.
type C = | CThere 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.
yes pre-PR this is giving an error:
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.
How about this case:
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.
d8073c2#diff-d59739c861a71a0c665896efcd95507dR4
question is: is that correct
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.
see also #1512 (comment)
Uh oh!
There was an error while loading. Please reload this page.
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 already described. this is breaking and #1814 show that this case builds in current master. It will break after this PR.
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.
@forki We need to make this change non-breaking. It seems to me you should first search non-RQA unions (emitting no warning), then type names, then RQA unions (emitting the warning)?
Uh oh!
There was an error while loading. Please reload this page.
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.
Like 398931e ?
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 think it's now backwards compatible