Skip to content
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

QuickFix for ValueNotContainedMutabilityLiteralConstantValuesDiffer #546

Draft
wants to merge 25 commits into
base: net233
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
b5f622a
Quickfix for difference in mutability in signature file.
nojaf Jul 5, 2023
676ef15
Update error message in the ID.
nojaf Jul 5, 2023
3e7d62e
Start working on quickfix for ValueNotContainedMutabilityLiteralConst…
dawedawe Jul 6, 2023
b94f311
rename
dawedawe Jul 7, 2023
243dc20
refactor
dawedawe Jul 7, 2023
9c36e72
update type in signature file if needed
dawedawe Jul 7, 2023
d6b0b5e
add test case with inline comments
dawedawe Jul 7, 2023
3139293
rename error to LiteralConstantValuesDifferError, no need to use the …
dawedawe Jul 10, 2023
1cd7b7c
format changes
dawedawe Jul 10, 2023
215b53a
check if type of impl can be resolved in sig before making fix available
dawedawe Jul 10, 2023
38dd977
- handle Literals with other Literals as their expression
dawedawe Jul 10, 2023
c2461c2
add test for complex expressions fom lang preview
dawedawe Jul 10, 2023
12c4470
improve naming of tests
dawedawe Jul 11, 2023
eb494d3
add overload of ResolveWithFcs that takes a context node
dawedawe Jul 12, 2023
cf75f65
add test with parens in the pattern
dawedawe Jul 12, 2023
3b96855
- improve naming
dawedawe Jul 12, 2023
119aca3
Add validation of binary expressions
dawedawe Jul 12, 2023
e8d43c8
the FCS error can also mean that the impl side lacks the Literal attr…
dawedawe Jul 13, 2023
4cf1127
- use IgnoreInnerParens()
dawedawe Jul 13, 2023
fc3f30a
tighten match of expression
dawedawe Jul 14, 2023
9b12f36
rename "UpdateLiteralConstantFix" to "UpdateLiteralConstantInSignatur…
dawedawe Jul 14, 2023
71d8675
rename error from "LiteralConstantValuesDiffer" to "LiteralConstantVa…
dawedawe Jul 14, 2023
18b5e8c
for the time being, don't offer the fix for measure constants
dawedawe Jul 26, 2023
35a4825
Support validation checks for Constants with units of measure types
dawedawe Jul 27, 2023
884e2a6
Don't update the return type for UoM as FSharpType.Format is currentl…
dawedawe Aug 23, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
format changes
  • Loading branch information
dawedawe committed Aug 22, 2023
commit 1cd7b7c6a19c70af4bd5e30e6ae36ceb776598d2
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,18 @@ type UpdateLiteralConstantFix(error: LiteralConstantValuesDifferError) =
let tryFindSigBindingSignature sigMembers =
sigMembers
|> Seq.tryPick(fun m ->
let bindingSignature = m.As<IBindingSignature>()
match bindingSignature with
| null -> None
| _ ->
match error.Pat.Binding.HeadPattern with
| :? IReferencePat as implPat ->
match bindingSignature.HeadPattern with
| :? IReferencePat as sigRefPat when
implPat.DeclaredName = sigRefPat.DeclaredName
-> Some bindingSignature
| _ -> None
let bindingSignature = m.As<IBindingSignature>()
Copy link
Member

Choose a reason for hiding this comment

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

Is there a similar error produced for enum value declarations? If yes, we should try to make it easy to enable the same quick fix in all cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll have a look at that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The error that is raised for enum values is also raised for record fields (FS193) and it's currently handled by UpdateRecordFieldTypeInSignatureFix. So I guess, we could expand that fix to also handle enums or merge it with the fix of this PR. Not sure yet, what's better.

match bindingSignature with
| null -> None
| _ ->
match error.Pat.Binding.HeadPattern with
| :? IReferencePat as implPat ->
match bindingSignature.HeadPattern with
| :? IReferencePat as sigRefPat when
Copy link
Member

Choose a reason for hiding this comment

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

Does it work with parens?

[<Literal>]
let (a) = 1

Are there any other compound patterns that are allowed in a literal binding?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question. I can't think of one. Do you have another in mind?

Copy link
Member

@auduchinok auduchinok Jul 13, 2023

Choose a reason for hiding this comment

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

I can't think of one.

Could you check it, please? I.e. look at what kind of patterns are possible to type there, then check if analysis allows them to be in a literal binding. Looking at FSharp.psi grammar will really help to see the possible options.

implPat.DeclaredName = sigRefPat.DeclaredName -> Some bindingSignature
| _ -> None
)
| _ -> None
)

let mutable sigRefPat = null

Expand Down