Skip to content
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

Weird behaviour with unit type #3887

Closed
vicuna opened this issue Nov 23, 2005 · 1 comment
Closed

Weird behaviour with unit type #3887

vicuna opened this issue Nov 23, 2005 · 1 comment
Labels

Comments

@vicuna
Copy link

vicuna commented Nov 23, 2005

Original bug ID: 3887
Reporter: berke
Status: closed (set by @garrigue on 2005-11-28T09:48:09Z)
Resolution: not a bug
Priority: normal
Severity: minor
Version: 3.09.0
Category: ~DO NOT USE (was: OCaml general)

Bug description

By mistake, I noticed that Ocaml accepts a type definition like
type t = ()
(instead of type t = unit) and behaves strangely after that, e.g.,

% ledit ocaml
Objective Caml version 3.09

type t = ();;

type t = ()

let x : unit = ();;

This expression has type t but is here used with type unit

@vicuna
Copy link
Author

vicuna commented Nov 23, 2005

Comment author: @mmottl

This is expected behaviour. "()" is a valid data constructor and of type "unit" by default. You have just defined this constructor to be of a different type, which explains the error message.

Note that you can also do the following:

type t = () | X

This issue can be closed.

@vicuna vicuna closed this as completed Nov 28, 2005
@vicuna vicuna added the bug label Mar 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant