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

strange typing errors #3646

Closed
vicuna opened this issue Sep 7, 2002 · 2 comments
Closed

strange typing errors #3646

vicuna opened this issue Sep 7, 2002 · 2 comments
Labels

Comments

@vicuna
Copy link

vicuna commented Sep 7, 2002

Original bug ID: 1377
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)

Bug description

Hi,

While ICFPing, I came upon some strange typing error messages.

The first one is :

class type ct = object
method m : l:int -> ct
end

let rec f (o : ct) =
let rec g o =
let x = o#m 1 in
g x in
g o

which is well typed accorded to caml if I remove the l label. Here is
the error I got:

This expression has type ct = < m : l:int -> ct > as 'a
but is here used with type 'a

The second one is ill-typed and get the same error message:

class type ct = object
method m : l:int -> int
end

let rec f (o : ct) =
let rec g o =
let x = o#m 1 in
g x in
g o

If I remove the label I got a stranger error:

This expression has type ct = < m : int -> int > as 'a
but is here used with type 'a
Type int is not compatible with type ct = 'a

Can someone explain that?

--
Dimitri Ara

@vicuna
Copy link
Author

vicuna commented Sep 9, 2002

Comment author: administrator

Thanks for you report.
This is now fixed in the CVS version:
Objective Caml version 3.06+1 (2002-09-07)

class type ct = object

method m : l:int -> int

end
let rec f (o : ct) =
let rec g o =
let x = o#m 1 in
g x in
g o;;
^
This expression has type ct = < m : l:int -> int > but is here used with type
< m : int -> 'a; .. > as 'a

Note that this code is semantically correct: you just need to add a type
annotation in g to make it typable.

Jacques Garrigue

@vicuna
Copy link
Author

vicuna commented Sep 9, 2002

Comment author: administrator

Fixed in ctype.ml by Jacques (2002-09-09)

@vicuna vicuna closed this as completed Sep 9, 2002
@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