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

Incorrect type inference with objects #4766

Closed
vicuna opened this issue Apr 9, 2009 · 1 comment
Closed

Incorrect type inference with objects #4766

vicuna opened this issue Apr 9, 2009 · 1 comment
Labels

Comments

@vicuna
Copy link

vicuna commented Apr 9, 2009

Original bug ID: 4766
Reporter: pveber
Status: closed (set by @garrigue on 2009-04-10T06:33:49Z)
Resolution: fixed
Priority: normal
Severity: major
Fixed in version: 3.11.1+dev
Category: ~DO NOT USE (was: OCaml general)

Bug description

Consider the following session with ocaml 3.11 interpreter :

    Objective Caml version 3.11.0

class virtual ['a] c =

object (s : 'a)
method virtual m : 'b
end
;;
class virtual ['a] c :
object ('a) constraint 'a = < m : 'b; .. > method virtual m : 'b end

let o =

object (s :'a)
  inherit ['a] c
  method m = 42
end;;

val o : 'a c as 'a = ...

o#m;;

  • : 'a =

It seems that the typing of instance o is incorrect, and should rather be something like 'a c as 'a constraint 'a = < m : int; .. >. I did not find any previous report of this problem. The behaviour is the same on ocaml 3.10.2.

BTW: thanks for your excellent work on ocaml, and all the very instructive messages sent by the caml dev team on caml-list.

@vicuna
Copy link
Author

vicuna commented Apr 10, 2009

Comment author: @garrigue

The real problem was in the way abbreviations were simplified in
Ctype.normalize_type.
Concretely, ('a c as 'a) does not accurately define a type, since it can describe any instance of itself too...

@vicuna vicuna closed this as completed Apr 10, 2009
@vicuna vicuna added the bug label Mar 20, 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