Skip to content

Commit 198bbc4

Browse files
authored
Add hint for #float (#1864)
Add hint for #float
1 parent ac1ac78 commit 198bbc4

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

ocaml/testsuite/tests/typing-layouts-float64/parsing.ml

+11
Original file line numberDiff line numberDiff line change
@@ -250,3 +250,14 @@ Line 1, characters 9-26:
250250
Error: The type constructor float# expects 0 argument(s),
251251
but is here applied to 2 argument(s)
252252
|}];;
253+
254+
(*******************)
255+
(* Hint for #float *)
256+
type t = #float;;
257+
[%%expect {|
258+
Line 1, characters 10-15:
259+
1 | type t = #float;;
260+
^^^^^
261+
Error: Unbound class type float
262+
Hint: Did you mean float#?
263+
|}]

ocaml/typing/env.ml

+6-1
Original file line numberDiff line numberDiff line change
@@ -3889,7 +3889,12 @@ let report_lookup_error _loc env ppf = function
38893889
end
38903890
| Unbound_cltype lid ->
38913891
fprintf ppf "Unbound class type %a" !print_longident lid;
3892-
spellcheck ppf extract_cltypes env lid;
3892+
begin match lid with
3893+
| Lident "float" ->
3894+
Misc.did_you_mean ppf (fun () -> ["float#"])
3895+
| Lident _ | Ldot _ | Lapply _ ->
3896+
spellcheck ppf extract_cltypes env lid
3897+
end;
38933898
| Unbound_instance_variable s ->
38943899
fprintf ppf "Unbound instance variable %s" s;
38953900
spellcheck_name ppf extract_instance_variables env s;

0 commit comments

Comments
 (0)