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

Fix srtp constraint printing #9728

Merged
merged 11 commits into from
Jul 22, 2020

Conversation

abelbraaksma
Copy link
Contributor

@abelbraaksma abelbraaksma commented Jul 21, 2020

Fixes #5768

TLDR: srtp contraints returning a function did not get pretty-printed for overloads-suggestions like 'a -> 'b -> ('x -> 'y), instead, you'd see 'a -> 'b -> 'x -> 'y. That is, the parens were omitted if a function was returned. Same is true for type or constraint missing errors.

This continues #5948. It was 2 years behind master, and creating a new PR seemed a simpler way to get this done. The changes w.r.t. that PR are small:

  • Renamed the new test neg111 to neg112 and
  • Renamed neg111.fs to neg112.fs and
  • Renamed neg111.bsl to neg112.bsl

Let's see what CI makes of this now ;).

@realvictorprm, this was originally your PR and I branched off your branch to keep the history intact. I hope it's ok that I try to continue & finish it ;). Since I cannot make changes to an existing PR, I decided to make a new one. I don't claim to know all details of your fix, but from the look of it, it seemed quite straight-forward and it was already reviewed & accepted as-is.

@abelbraaksma
Copy link
Contributor Author

abelbraaksma commented Jul 21, 2020

Hmm, I'm now suddenly locally getting this:

D:\Projects\OpenSource\FSharp\artifacts\obj\PEVerify\Debug\net472\PEVerify.AssemblyInfo.cs(14,12): error CS0579: Duplicate 'System.Reflection.AssemblyCompanyAttribute' attribute [D:\Projects\OpenSource\FSharp\tests\fsharpqa\testenv\src\PEVerify\PEVerify.csproj]
D:\Projects\OpenSource\FSharp\artifacts\obj\PEVerify\Debug\net472\PEVerify.AssemblyInfo.cs(15,12): error CS0579: Duplicate 'System.Reflection.AssemblyConfigurationAttribute' attribute [D:\Projects\OpenSource\FSharp\tests\fsharpqa\testenv\src\PEVerify\PEVerify.csproj]
D:\Projects\OpenSource\FSharp\artifacts\obj\PEVerify\Debug\net472\PEVerify.AssemblyInfo.cs(17,12): error CS0579: Duplicate 'System.Reflection.AssemblyFileVersionAttribute' attribute [D:\Projects\OpenSource\FSharp\tests\fsharpqa\testenv\src\PEVerify\PEVerify.csproj]
D:\Projects\OpenSource\FSharp\artifacts\obj\PEVerify\Debug\net472\PEVerify.AssemblyInfo.cs(18,12): error CS0579: Duplicate 'System.Reflection.AssemblyInformationalVersionAttribute' attribute [D:\Projects\OpenSource\FSharp\tests\fsharpqa\testenv\src\PEVerify\PEVerify.csproj]
D:\Projects\OpenSource\FSharp\artifacts\obj\PEVerify\Debug\net472\PEVerify.AssemblyInfo.cs(19,12): error CS0579: Duplicate 'System.Reflection.AssemblyProductAttribute' attribute [D:\Projects\OpenSource\FSharp\tests\fsharpqa\testenv\src\PEVerify\PEVerify.csproj]
D:\Projects\OpenSource\FSharp\artifacts\obj\PEVerify\Debug\net472\PEVerify.AssemblyInfo.cs(20,12): error CS0579: Duplicate 'System.Reflection.AssemblyTitleAttribute' attribute [D:\Projects\OpenSource\FSharp\tests\fsharpqa\testenv\src\PEVerify\PEVerify.csproj]
D:\Projects\OpenSource\FSharp\artifacts\obj\PEVerify\Debug\net472\PEVerify.AssemblyInfo.cs(21,12): error CS0579: Duplicate 'System.Reflection.AssemblyVersionAttribute' attribute [D:\Projects\OpenSource\FSharp\tests\fsharpqa\testenv\src\PEVerify\PEVerify.csproj]

Haven't seen it before in this solution. I understand the error, but the file is auto-generated. Wonder if it has something to do with me merging 2 years of stuff. Hope CI doesn't see this ;).

EDIT: git clean -xdf and then build fixed it. Normal build -rebuild etc didn't.

@abelbraaksma
Copy link
Contributor Author

Some errors like the following, but these were expected, as these tests were added after this change and are related to the stringification of constraints. I'll look into them

-  - static member Neg117.Superpower.Transformer.Transform :  ^f * Neg117.TargetB.TargetB * Neg117.Superpower.Transformer -> (Neg117.TargetB.TransformerKind ->  ^f) when (Neg117.TargetB.TargetB or  ^f) : (static member Transform :  ^f * Neg117.TargetB.TargetB -> Neg117.TargetB.TransformerKind ->  ^f) // Argument at index 1 doesn't match
+  - static member Neg117.Superpower.Transformer.Transform :  ^f * Neg117.TargetB.TargetB * Neg117.Superpower.Transformer -> (Neg117.TargetB.TransformerKind ->  ^f) when (Neg117.TargetB.TargetB or  ^f) : (static member Transform :  ^f * Neg117.TargetB.TargetB -> (Neg117.TargetB.TransformerKind ->  ^f)) // Argument at index 1 doesn't match
diff between [D:\a\1\s\tests\fsharp\typecheck\sigs\neg117.bsl] and [D:\a\1\s\tests\fsharp\typecheck\sigs\neg117.err]
line 10

@abelbraaksma
Copy link
Contributor Author

abelbraaksma commented Jul 21, 2020

The relevant part of the above changed message is:

- when (Neg117.TargetB.TargetB or  ^f) : (static member Transform :  ^f * Neg117.TargetB.TargetB -> Neg117.TargetB.TransformerKind ->  ^f)
+ when (Neg117.TargetB.TargetB or  ^f) : (static member Transform :  ^f * Neg117.TargetB.TargetB -> (Neg117.TargetB.TransformerKind ->  ^f)) 

Note the extra parens that now correctly indicate a function is returned. It now mimics the tooltip:

image

Same for the other failed test, and a fix to pick the correct directory for the new test.

@abelbraaksma
Copy link
Contributor Author

abelbraaksma commented Jul 22, 2020

Interesting, with the 2 years worth of merging, instead of 3x a version of the FS0001 type error, it now has 1x FS0001 and 2x FS0043, which reminded me of this old issue: #3508.

I'm however at a loss why the error is mentioned 3x in the *.bsl file. Whenever I run the code in FSI I get the first error only once. With fsc.exe I get it three times:

image

(the 3x reporting was already like this when the PR was first created, except that the error numbers are different now, and this is not related to this PR per se, this PR only fixes the correct signature for the overloads, or missing constraints).

This makes me wonder what the difference is between FS0001 and FS0043, considering the texts are equal (as also observed in #3508). Maybe we're issuing the wrong error number with the right text, or vv?

@abelbraaksma
Copy link
Contributor Author

Green, @cartermp, this is ready.

@realvictorprm, do you want to review this? Or you think it's good as is?

Copy link
Contributor

@cartermp cartermp left a comment

Choose a reason for hiding this comment

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

Thanks! Approving since the change looks good and is straightforward. Since @dsyme approved the prior attempt, I'll merge this.

@cartermp cartermp merged commit 47c432b into dotnet:master Jul 22, 2020
@abelbraaksma abelbraaksma deleted the fix-srtp-constraint-printing branch July 25, 2020 21:09
nosami pushed a commit to xamarin/visualfsharp that referenced this pull request Feb 23, 2021
* Fix dotnet#5768
Corrected wrong formatted print of a trait member constraint

Signed-off-by: realvictorprm <[email protected]>

* Adding regression test.

Signed-off-by: realvictorprm <[email protected]>

* Fix test to expect an error.

Signed-off-by: realvictorprm <[email protected]>

* Apply review, move and add new test to typecheck\sigs.

Signed-off-by: realvictorprm <[email protected]>

* Rename neg111 to neg112 to ease merging

* Bring layoutReturnType into scope, and use instead of layoutTypeWithInfoAndPrec

* Fix test neg112 to use proper directory

* Fix tests that suggest overloads to use parens around returned functions

* Mention correct file and col numbers in new neg112 test

Co-authored-by: realvictorprm <[email protected]>
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.

SRTP reports a required constraint (twice) that has already been specified
3 participants