From 8e3b4c875b44553257e5480e0801701089b63227 Mon Sep 17 00:00:00 2001 From: realvictorprm Date: Thu, 22 Nov 2018 15:08:25 +0100 Subject: [PATCH 1/4] Fix #5768 Corrected wrong formatted print of a trait member constraint Signed-off-by: realvictorprm --- src/fsharp/NicePrint.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fsharp/NicePrint.fs b/src/fsharp/NicePrint.fs index ef865b0afa..a5f79403b8 100755 --- a/src/fsharp/NicePrint.fs +++ b/src/fsharp/NicePrint.fs @@ -872,7 +872,7 @@ module private PrintTypes = | tys -> bracketL (layoutTypesWithInfoAndPrec denv env 2 (wordL (tagKeyword "or")) tys) tysL ^^ wordL (tagPunctuation ":") --- bracketL (stat ++ wordL (tagMember nm) ^^ wordL (tagPunctuation ":") --- - ((layoutTypesWithInfoAndPrec denv env 2 (wordL (tagPunctuation "*")) argtys --- wordL (tagPunctuation "->")) --- (layoutTypeWithInfo denv env rty))) + ((layoutTypesWithInfoAndPrec denv env 2 (wordL (tagPunctuation "*")) argtys --- wordL (tagPunctuation "->")) --- (layoutTypeWithInfoAndPrec denv env 4 rty))) /// Layout a unit expression From 759ec97324365a038a3b9546514539d9a17bf32b Mon Sep 17 00:00:00 2001 From: realvictorprm Date: Sat, 1 Dec 2018 12:21:25 +0100 Subject: [PATCH 2/4] Adding regression test. Signed-off-by: realvictorprm --- tests/fsharp/regression/5768/test.bsl | 5 +++++ tests/fsharp/regression/5768/test.fs | 22 ++++++++++++++++++++++ tests/fsharp/tests.fs | 16 ++++++++++++++++ 3 files changed, 43 insertions(+) create mode 100644 tests/fsharp/regression/5768/test.bsl create mode 100644 tests/fsharp/regression/5768/test.fs diff --git a/tests/fsharp/regression/5768/test.bsl b/tests/fsharp/regression/5768/test.bsl new file mode 100644 index 0000000000..8f14a864da --- /dev/null +++ b/tests/fsharp/regression/5768/test.bsl @@ -0,0 +1,5 @@ +test.fs(20,49): error FS0001: A type parameter is missing a constraint 'when (Tuple or ^options) : (static member TupleMap : ^options * Tuple -> (('item -> ^value) -> ^values))' + +test.fs(20,49): error FS0001: A type parameter is missing a constraint 'when (Tuple or ^options) : (static member TupleMap : ^options * Tuple -> (('item -> ^value) -> ^values))' + +test.fs(20,49): error FS0001: A type parameter is missing a constraint 'when (Tuple or ^options) : (static member TupleMap : ^options * Tuple -> (('item -> ^value) -> ^values))' \ No newline at end of file diff --git a/tests/fsharp/regression/5768/test.fs b/tests/fsharp/regression/5768/test.fs new file mode 100644 index 0000000000..b544ee5834 --- /dev/null +++ b/tests/fsharp/regression/5768/test.fs @@ -0,0 +1,22 @@ +module Something +type Tuple = + static member inline TupleMap ((a, b), _ : Tuple) = fun f -> (f a, f b) + static member inline TupleMap ((a, b, c), _ : Tuple) = fun f -> (f a, f b, f c) + static member inline TupleMap ((a, b, c, d), _ : Tuple) = fun f -> (f a, f b, f c, f d) + + static member inline Map f (x: 'Tin) : 'Tout = + let inline call_2 (a: ^a, b : ^b) = ((^a or ^b) : (static member TupleMap : ^b * _ -> ^t) (b, a)) + call_2 (Unchecked.defaultof, x) f + +type IOption<'T> = + abstract member Value : 'T + +let inline tupleMap f x = Tuple.Map f x + +let inline addOptionValues< ^value, ^options, ^values, 'item when + 'item :> IOption< ^value>> + (addUp : ^values -> ^value, sourceOptions : ^options) = + let getValue (i : 'item) = i.Value + let allValues : ^values = tupleMap getValue sourceOptions + let result : ^value = addUp allValues + result diff --git a/tests/fsharp/tests.fs b/tests/fsharp/tests.fs index d29f92e5e7..b945dff4a9 100644 --- a/tests/fsharp/tests.fs +++ b/tests/fsharp/tests.fs @@ -1737,6 +1737,22 @@ module RegressionTests = peverify cfg "test.exe" #endif +#if !FSHARP_SUITE_DRIVES_CORECLR_TESTS + [] + let ``5768`` () = + let cfg = testConfig "regression/5768" + let outFile = "test.out.bsl" + let expectedFile = "test.bsl" + + fscBothToOut cfg outFile "%s --nologo --target:library" cfg.fsc_flags ["test.fs"] + + let diff = fsdiff cfg outFile expectedFile + + match diff with + | "" -> () + | _ -> + Assert.Fail (sprintf "'%s' and '%s' differ; %A" (getfullpath cfg outFile) (getfullpath cfg expectedFile) diff) +#endif #if !FSHARP_SUITE_DRIVES_CORECLR_TESTS module OptimizationTests = From 1ca60569eaf5533c37eebae707790aea563ec7a2 Mon Sep 17 00:00:00 2001 From: realvictorprm Date: Sun, 2 Dec 2018 11:48:16 +0100 Subject: [PATCH 3/4] Fix test to expect an error. Signed-off-by: realvictorprm --- tests/fsharp/tests.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/fsharp/tests.fs b/tests/fsharp/tests.fs index b945dff4a9..60d6b73e40 100644 --- a/tests/fsharp/tests.fs +++ b/tests/fsharp/tests.fs @@ -1744,7 +1744,7 @@ module RegressionTests = let outFile = "test.out.bsl" let expectedFile = "test.bsl" - fscBothToOut cfg outFile "%s --nologo --target:library" cfg.fsc_flags ["test.fs"] + fscAppendErrExpectFail cfg outFile "%s --nologo --target:library" cfg.fsc_flags ["test.fs"] let diff = fsdiff cfg outFile expectedFile From 2d34b07c8ad235709f42abcc474dfbbd264a89b1 Mon Sep 17 00:00:00 2001 From: realvictorprm Date: Sun, 30 Dec 2018 15:57:39 +0100 Subject: [PATCH 4/4] Apply review, move and add new test to typecheck\sigs. Signed-off-by: realvictorprm --- tests/fsharp/tests.fs | 19 +++---------------- .../test.bsl => typecheck/sigs/neg111.bsl} | 1 + .../5768/test.fs => typecheck/sigs/neg111.fs} | 0 3 files changed, 4 insertions(+), 16 deletions(-) rename tests/fsharp/{regression/5768/test.bsl => typecheck/sigs/neg111.bsl} (99%) rename tests/fsharp/{regression/5768/test.fs => typecheck/sigs/neg111.fs} (100%) diff --git a/tests/fsharp/tests.fs b/tests/fsharp/tests.fs index 60d6b73e40..681f7f3994 100644 --- a/tests/fsharp/tests.fs +++ b/tests/fsharp/tests.fs @@ -1737,22 +1737,6 @@ module RegressionTests = peverify cfg "test.exe" #endif -#if !FSHARP_SUITE_DRIVES_CORECLR_TESTS - [] - let ``5768`` () = - let cfg = testConfig "regression/5768" - let outFile = "test.out.bsl" - let expectedFile = "test.bsl" - - fscAppendErrExpectFail cfg outFile "%s --nologo --target:library" cfg.fsc_flags ["test.fs"] - - let diff = fsdiff cfg outFile expectedFile - - match diff with - | "" -> () - | _ -> - Assert.Fail (sprintf "'%s' and '%s' differ; %A" (getfullpath cfg outFile) (getfullpath cfg expectedFile) diff) -#endif #if !FSHARP_SUITE_DRIVES_CORECLR_TESTS module OptimizationTests = @@ -2426,6 +2410,9 @@ module TypecheckTests = [] let ``type check neg110`` () = singleNegTest (testConfig "typecheck/sigs") "neg110" + [] + let ``type check neg111`` () = singleNegTest (testConfig "typecheck/sigs") "neg111" + [] let ``type check neg_issue_3752`` () = singleNegTest (testConfig "typecheck/sigs") "neg_issue_3752" diff --git a/tests/fsharp/regression/5768/test.bsl b/tests/fsharp/typecheck/sigs/neg111.bsl similarity index 99% rename from tests/fsharp/regression/5768/test.bsl rename to tests/fsharp/typecheck/sigs/neg111.bsl index 8f14a864da..f41d139d5e 100644 --- a/tests/fsharp/regression/5768/test.bsl +++ b/tests/fsharp/typecheck/sigs/neg111.bsl @@ -1,3 +1,4 @@ + test.fs(20,49): error FS0001: A type parameter is missing a constraint 'when (Tuple or ^options) : (static member TupleMap : ^options * Tuple -> (('item -> ^value) -> ^values))' test.fs(20,49): error FS0001: A type parameter is missing a constraint 'when (Tuple or ^options) : (static member TupleMap : ^options * Tuple -> (('item -> ^value) -> ^values))' diff --git a/tests/fsharp/regression/5768/test.fs b/tests/fsharp/typecheck/sigs/neg111.fs similarity index 100% rename from tests/fsharp/regression/5768/test.fs rename to tests/fsharp/typecheck/sigs/neg111.fs