From 6fcc2be51385cde77793a94b145200400a2ad9ca Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Thu, 8 Dec 2022 13:39:20 +0100 Subject: [PATCH] Restore error where uncurried type is expected. See https://github.com/rescript-lang/rescript-compiler/issues/5888 --- .../expected/uncurried_expected.res.expected | 9 +++++++++ .../super_errors/fixtures/uncurried_expected.res | 2 ++ jscomp/ml/typecore.ml | 4 ---- jscomp/super_errors/super_typecore.ml | 2 +- 4 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 jscomp/build_tests/super_errors/expected/uncurried_expected.res.expected create mode 100644 jscomp/build_tests/super_errors/fixtures/uncurried_expected.res diff --git a/jscomp/build_tests/super_errors/expected/uncurried_expected.res.expected b/jscomp/build_tests/super_errors/expected/uncurried_expected.res.expected new file mode 100644 index 0000000000..cb4afd42cf --- /dev/null +++ b/jscomp/build_tests/super_errors/expected/uncurried_expected.res.expected @@ -0,0 +1,9 @@ + + We've found a bug for you! + /.../fixtures/uncurried_expected.res:2:15-22 + + 1 │ let apply = (f) => f(. 1) + 2 │ let z = apply(x => x+1) + 3 │ + + This expression is expected to have an uncurried function \ No newline at end of file diff --git a/jscomp/build_tests/super_errors/fixtures/uncurried_expected.res b/jscomp/build_tests/super_errors/fixtures/uncurried_expected.res new file mode 100644 index 0000000000..6fad3ef0ab --- /dev/null +++ b/jscomp/build_tests/super_errors/fixtures/uncurried_expected.res @@ -0,0 +1,2 @@ +let apply = (f) => f(. 1) +let z = apply(x => x+1) diff --git a/jscomp/ml/typecore.ml b/jscomp/ml/typecore.ml index 6ba5b4f0f6..25527b7d74 100644 --- a/jscomp/ml/typecore.ml +++ b/jscomp/ml/typecore.ml @@ -3755,10 +3755,6 @@ let report_error env ppf = function fprintf ppf "it should have type@ %a" type_expr ty end else begin - match ty with - | {desc = Tconstr (Pdot (Pdot(Pident {name = "Js"},"Fn",_),_,_),_,_)} -> - fprintf ppf "This expression is excpeted to have an uncurried function" - | _ -> fprintf ppf "This expression should not be a function,@ "; fprintf ppf "the expected type is@ %a" type_expr ty diff --git a/jscomp/super_errors/super_typecore.ml b/jscomp/super_errors/super_typecore.ml index e91282740b..cef6a7ec0a 100644 --- a/jscomp/super_errors/super_typecore.ml +++ b/jscomp/super_errors/super_typecore.ml @@ -230,7 +230,7 @@ let report_error env ppf = function type_expr ty end else begin match ty with - | {desc = Tconstr (Pdot (Pdot(Pident {name = "Js"},"Fn",_),_,_),_,_)} -> + | {desc = Tconstr (Pident {name = "function$"},_,_)} -> fprintf ppf "This expression is expected to have an uncurried function" | _ -> fprintf ppf "@[This expression should not be a function,@ ";