8000 Redefining constructor () with an argument breaks everything · Issue #417 · ocaml-community/utop · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Redefining constructor () with an argument breaks everything #417

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

Closed
yannl35133 opened this issue Feb 23, 2023 · 1 comment · Fixed by #418 or ocaml/opam-repository#23681
Closed

Comments

@yannl35133
Copy link
yannl35133 commented Feb 23, 2023
utop # type t = () of unit
Line 1, characters 0-19:
Warning 65 [redefining-unit]: This type declaration is defining a new '()' constructor
which shadows the existing one.
Hint: Did you mean 'type t = unit'?
type t = () of unit
utop # let a = 0;;
Error: The constructor () expects 1 argument(s),
       but is applied here to 0 argument(s)

As far as I can tell every subsequent command fails with the same error

Edit: it doesn't happen in the ocaml toplevel

@emillon
Copy link
Collaborator
emillon commented Feb 23, 2023

We're building LIdent "()" in a couple of places. I'll try to fix that properly. Thanks for the bug report.

emillon added a commit to emillon/utop that referenced this issue Feb 23, 2023
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 ocaml-community#417
emillon added a commit to emillon/utop that referenced this issue Feb 23, 2023
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 ocaml-community#417
emillon added a commit to emillon/utop that referenced this issue Apr 17, 2023
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 ocaml-community#417
emillon added a commit that referenced this issue Apr 17, 2023
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
emillon added a commit to emillon/opam-repository that referenced this issue Apr 17, 2023
CHANGES:

* Add support for OCaml 5.1 (ocaml-community/utop#421, @emillon)

* Mark `prompt_continue`, `prompt_comment`, `smart_accept`, `new_prompt_hooks`,
  `at_new_prompt` as deprecated (they have been documented as such since 2012
  and most of them are ignored) (ocaml-community/utop#415, @emillon)

* Qualify `()` constructor in generated expressions. (ocaml-community/utop#418, fixes ocaml-community/utop#417, @emillon)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants
0