Skip to content

Clean up Super_error #6199

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

Merged
merged 11 commits into from
Apr 27, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
14 changes: 14 additions & 0 deletions jscomp/build_tests/super_errors/expected/type2.res.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

We've found a bug for you!
/.../fixtures/type2.res:6:11-13

4 │ let () = {
5 │ push(a, 3)->ignore
6 │ push(a, "3")->ignore
7 │ }
8 │

This has type: string
Somewhere wanted: int

You can convert string to int with Belt.Int.fromString.
13 changes: 13 additions & 0 deletions jscomp/build_tests/super_errors/expected/type3.res.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

We've found a bug for you!
/.../fixtures/type3.res:1:5

1 │ let u = []
2 │

This expression's type contains type variables that cannot be generalized:
array<'_weak1>

This happens when the type system senses there's a mutation/side-effect,
in combination with a polymorphic value.
Using or annotating that value usually solves it.
7 changes: 7 additions & 0 deletions jscomp/build_tests/super_errors/fixtures/type2.res
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@send external push: (array<'a>, 'a) => unit = "push"

let a = []
let () = {
push(a, 3)->ignore
push(a, "3")->ignore
}
1 change: 1 addition & 0 deletions jscomp/build_tests/super_errors/fixtures/type3.res
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
let u = []
8 changes: 4 additions & 4 deletions jscomp/ounit_tests/ounit_cmd_tests.ml
Original file line number Diff line number Diff line change
Expand Up @@ -276,14 +276,14 @@ let rec y = A y;;
OUnit.assert_bool __LOC__
(Ext_string.contain_substring should_err.stderr "contravariant")
end;
__LOC__ >:: begin fun _ ->
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would you delete instead of commenting out?

Copy link
Member Author

Choose a reason for hiding this comment

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

(* __LOC__ >:: begin fun _ ->
let should_err = bsc_check_eval {|
let u = [||]
|} in
OUnit.assert_bool __LOC__
(Ext_string.contain_substring should_err.stderr "cannot be generalized")
end;
__LOC__ >:: begin fun _ ->
end; *)
(* __LOC__ >:: begin fun _ ->
let should_err = bsc_check_eval {|
external push : 'a array -> 'a -> unit = "push" [@@send]
let a = [||]
Expand All @@ -293,7 +293,7 @@ let () =
|} in
OUnit.assert_bool __LOC__
(Ext_string.contain_substring should_err.stderr "string")
end
end *)
(* __LOC__ >:: begin fun _ -> *)
(* let should_infer = perform_bsc [| "-i"; "-bs-eval"|] {| *)
(* let f = fun [@bs] x -> let (a,b) = x in a + b *)
Expand Down