Skip to content

Commit ed89528

Browse files
committed
Qualify () constructor
We are building a hidden expression that contains "()" but it is not qualified. So it will pick the constructor in scope. This can cause problems if `()` has been redefined. The correct fix is to qualify it as part of the `Unit` module. (additionally, this removes an unused ident) Fixes #417
1 parent 1a70e0f commit ed89528

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

CHANGES.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33

44
* Mark `prompt_continue`, `prompt_comment`, `smart_accept`, `new_prompt_hooks`,
55
`at_new_prompt` as deprecated (they have been documented as such since 2012
6-
and most of them are ignored) (#xxx @emillon)
6+
and most of them are ignored) (#415, @emillon)
7+
8+
* Qualify `()` constructor in generated expressions. (#418, fixes #417, @emillon)
79

810
2.11.0 (2023-01-05)
911
-------------------

src/lib/uTop.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ let check_phrase phrase =
349349
let env = !Toploop.toplevel_env in
350350
(* Construct "let _ () = let module _ = struct <items> end in ()" in order to test
351351
the typing and compilation of [items] without evaluating them. *)
352-
let unit = with_loc loc (Longident.Lident "()") in
352+
let unit = with_loc loc (Longident.Ldot (Lident "Unit", "()")) in
353353
let top_def =
354354
let open Ast_helper in
355355
with_default_loc loc

src/lib/uTop_main.ml

-1
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,6 @@ type rewrite_rule = {
574574
let longident_lwt_main_run = Longident.Ldot (Longident.Lident "Lwt_main", "run")
575575
let longident_async_thread_safe_block_on_async_exn =
576576
Longident.(Ldot (Ldot (Lident "Async", "Thread_safe"), "block_on_async_exn"))
577-
let longident_unit = Longident.Lident "()"
578577

579578
let rewrite_rules = [
580579
(* Rewrite Lwt.t expressions to Lwt_main.run <expr> *)

0 commit comments

Comments
 (0)