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

Wrong type is reported in type mismatch error #13347

Merged

Conversation

edgarfgp
Copy link
Contributor

Fixes #13192 .

@smoothdeveloper
Copy link
Contributor

@edgarfgp thanks for looking into this!

Would you mind adding "negtests" similar to those defined in this file

fsharp/tests/fsharp/tests.fs

Lines 3374 to 3405 in 4be3bb5

module OverloadResolution =
module ``fsharpqa migrated tests`` =
let [<Test>] ``Conformance\Expressions\SyntacticSugar (E_Slices01.fs)`` () = singleNegTest (testConfig "conformance/expressions/syntacticsugar") "E_Slices01"
let [<Test>] ``Conformance\Expressions\Type-relatedExpressions (E_RigidTypeAnnotation03.fsx)`` () = singleNegTest (testConfig "conformance/expressions/type-relatedexpressions") "E_RigidTypeAnnotation03"
let [<Test>] ``Conformance\Inference (E_OneTypeVariable03.fs)`` () = singleNegTest (testConfig "conformance/inference") "E_OneTypeVariable03"
let [<Test>] ``Conformance\Inference (E_OneTypeVariable03rec.fs)`` () = singleNegTest (testConfig "conformance/inference") "E_OneTypeVariable03rec"
let [<Test>] ``Conformance\Inference (E_TwoDifferentTypeVariablesGen00.fs)`` () = singleNegTest (testConfig "conformance/inference") "E_TwoDifferentTypeVariablesGen00"
let [<Test>] ``Conformance\Inference (E_TwoDifferentTypeVariables01.fs)`` () = singleNegTest (testConfig "conformance/inference") "E_TwoDifferentTypeVariables01"
let [<Test>] ``Conformance\Inference (E_TwoDifferentTypeVariables01rec.fs)`` () = singleNegTest (testConfig "conformance/inference") "E_TwoDifferentTypeVariables01rec"
let [<Test>] ``Conformance\Inference (E_TwoDifferentTypeVariablesGen00rec.fs)`` () = singleNegTest (testConfig "conformance/inference") "E_TwoDifferentTypeVariablesGen00rec"
let [<Test>] ``Conformance\Inference (E_TwoEqualTypeVariables02.fs)`` () = singleNegTest (testConfig "conformance/inference") "E_TwoEqualTypeVariables02"
let [<Test>] ``Conformance\Inference (E_TwoEqualYypeVariables02rec.fs)`` () = singleNegTest (testConfig "conformance/inference") "E_TwoEqualYypeVariables02rec"
let [<Test>] ``Conformance\Inference (E_LeftToRightOverloadResolution01.fs)`` () = singleNegTest (testConfig "conformance/inference") "E_LeftToRightOverloadResolution01"
let [<Test>] ``Conformance\WellFormedness (E_Clashing_Values_in_AbstractClass01.fs)`` () = singleNegTest (testConfig "conformance/wellformedness") "E_Clashing_Values_in_AbstractClass01"
let [<Test>] ``Conformance\WellFormedness (E_Clashing_Values_in_AbstractClass03.fs)`` () = singleNegTest (testConfig "conformance/wellformedness") "E_Clashing_Values_in_AbstractClass03"
let [<Test>] ``Conformance\WellFormedness (E_Clashing_Values_in_AbstractClass04.fs)`` () = singleNegTest (testConfig "conformance/wellformedness") "E_Clashing_Values_in_AbstractClass04"
// note: this test still exist in fsharpqa to assert the compiler doesn't crash
// the part of the code generating a flaky error due to /~https://github.com/dotnet/fsharp/issues/6725
// is elided here to focus on overload resolution error messages
let [<Test>] ``Conformance\LexicalAnalysis\SymbolicOperators (E_LessThanDotOpenParen001.fs)`` () = singleNegTest (testConfig "conformance/lexicalanalysis") "E_LessThanDotOpenParen001"
module ``error messages using BCL``=
let [<Test>] ``neg_System.Convert.ToString.OverloadList``() = singleNegTest (testConfig "typecheck/overloads") "neg_System.Convert.ToString.OverloadList"
let [<Test>] ``neg_System.Threading.Tasks.Task.Run.OverloadList``() = singleNegTest (testConfig "typecheck/overloads") "neg_System.Threading.Tasks.Task.Run.OverloadList"
let [<Test>] ``neg_System.Drawing.Graphics.DrawRectangleOverloadList.fsx``() = singleNegTest (testConfig "typecheck/overloads") "neg_System.Drawing.Graphics.DrawRectangleOverloadList"
module ``ad hoc code overload error messages``=
let [<Test>] ``neg_many_many_overloads`` () = singleNegTest (testConfig "typecheck/overloads") "neg_many_many_overloads"
let [<Test>] ``neg_interface_generics`` () = singleNegTest (testConfig "typecheck/overloads") "neg_interface_generics"
let [<Test>] ``neg_known_return_type_and_known_type_arguments`` () = singleNegTest (testConfig "typecheck/overloads") "neg_known_return_type_and_known_type_arguments"
let [<Test>] ``neg_generic_known_argument_types`` () = singleNegTest (testConfig "typecheck/overloads") "neg_generic_known_argument_types"
let [<Test>] ``neg_tupled_arguments`` () = singleNegTest (testConfig "typecheck/overloads") "neg_tupled_arguments"

Those test make sure the type checker error match desired output (that is error message with correct type mismatch info).

@edgarfgp edgarfgp force-pushed the wrong-type-is-reported-in-type-mismatch-error branch 2 times, most recently from dd3c2d8 to 674cb0f Compare July 9, 2022 11:09
@edgarfgp
Copy link
Contributor Author

Unfortunately I do not have the enough knowledge regarding error recovering to fix It is 50 % done IMO . Would be awesome if someone can take this one and finished it. I think would be a good improvement to have :) . Thanks
@smoothdeveloper and @auduchinok for the pointers though .

@edgarfgp edgarfgp force-pushed the wrong-type-is-reported-in-type-mismatch-error branch from 674cb0f to f0274f6 Compare August 7, 2022 08:53
@vzarytovskii vzarytovskii marked this pull request as draft September 8, 2022 13:02
Copy link
Member

@auduchinok auduchinok left a comment

Choose a reason for hiding this comment

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

@0101 This looks very nice!

@0101 0101 marked this pull request as ready for review September 22, 2022 15:52
@0101
Copy link
Contributor

0101 commented Sep 22, 2022

Gave this another go with @dsyme and I think it's now ready :)

@edgarfgp
Copy link
Contributor Author

@0101 This looks really good :) . Any thing pending to be ready for merge ?

@0101
Copy link
Contributor

0101 commented Oct 13, 2022

@edgarfgp I'd like to get @dsyme's review :) Or at minimum some other reviews...

T-Gro
T-Gro previously approved these changes Oct 17, 2022
dsyme
dsyme previously approved these changes Oct 17, 2022
@dsyme
Copy link
Contributor

dsyme commented Oct 17, 2022

Really good work!!! And so glad to see us making these core improvements

@0101 0101 dismissed stale reviews from dsyme and T-Gro via cc56c30 October 17, 2022 11:31
Copy link
Member

@auduchinok auduchinok left a comment

Choose a reason for hiding this comment

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

It looks really great, the errors are much better now, thanks!

@0101 0101 enabled auto-merge (squash) October 17, 2022 15:14
@0101 0101 merged commit 8ba53ff into dotnet:main Oct 17, 2022
@dsyme
Copy link
Contributor

dsyme commented Oct 17, 2022

@edgarfgp @0101 Yay! 🥳 🥳 🥳

@edgarfgp
Copy link
Contributor Author

Thanks for making this happen . I have learn so much my reviewing this code :)

@0101
Copy link
Contributor

0101 commented Oct 18, 2022

@edgarfgp @dsyme optional continuation here: #14003 🙂

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

Successfully merging this pull request may close these issues.

Wrong type is reported in type mismatch error
7 participants