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

Polymorphic variants problem. #3332

Closed
vicuna opened this issue May 3, 2002 · 4 comments
Closed

Polymorphic variants problem. #3332

vicuna opened this issue May 3, 2002 · 4 comments
Labels

Comments

@vicuna
Copy link

vicuna commented May 3, 2002

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

Bug description

Hi,
I'm not sure if anyone caught this from the mailing list, but in case
no one did, here is the original mail
http://caml.inria.fr/archives/200204/msg00363.html
from Nadji Gauthier.

 The reason I think it is a bug is that the type error only shows up

when the marked Printf line is uncommented from pvmain.ml, but it compiles
fine when the Printf isn't there. The error report is

File "pvmain.ml", line 4, characters 11-22:
The type of this expression, [ D2 of [ D3 of [ `U]]] Pvdim.dec,
contains type variables that cannot be generalized


(* pvmain.ml *)

open Pvdim

let x120 = (d0 (d2 (d1 dec)))
let x32 = (d2 (d3 dec)) (* <--- Bug shows up here! *)
let f_nz (x:[< 'a digit ] dec) = to_int x
let x0 = dec and x1 = (d1 dec)
type 'a atleast5 =
[ D5 of 'a | D6 of 'a | D7 of 'a | D8 of 'a | D9 of 'a ] and 'a atmost4 = [D0 of 'a | D1 of 'a | D2 of 'a | D3 of 'a | D4 of 'a ]
let f_atleast5 (x:[<
| [< 'a digit ] atmost4
| [< `U | 'a digit ] atleast5] dec) = to_int x

let _ =
Printf.printf "Result should be 32, is %d\n" (Pvdim.to_int x32);
(* ^^^ Uncomment this Printf to reveal bug ^^^
Printf.printf "Result should be 32, is %d\n" (f_atleast5 x32);
*)
()

(* pvdim.mli *)
type 'a dec

val dec : [`U] dec
val to_int : 'a dec -> int

type 'a digit =
[D0 of 'a | D1 of 'a | D2 of 'a | D3 of 'a | D4 of 'a | D5 of 'a | D6 of 'a | D7 of 'a | D8 of 'a | D9 of 'a ]

val d0 : ([< 'a digit ] as 'd) dec -> [D0 of 'd] dec val d1 : 'a dec -> [D1 of 'a] dec
val d2 : 'a dec -> [D2 of 'a] dec val d3 : 'a dec -> [D3 of 'a] dec
val d4 : 'a dec -> [D4 of 'a] dec val d5 : 'a dec -> [D5 of 'a] dec
val d6 : 'a dec -> [D6 of 'a] dec val d7 : 'a dec -> [D7 of 'a] dec
val d8 : 'a dec -> [D8 of 'a] dec val d9 : 'a dec -> [D9 of 'a] dec

(* pvdim.ml *)
type 'a digit =
[ D0 of 'a | D1 of 'a | D2 of 'a | D3 of 'a | D4 of 'a | D5 of 'a | D6 of 'a | D7 of 'a | D8 of 'a | D9 of
'a ]
type 'a dec = int

let dec = 0
let to_int x = x

let mkd n = fun d -> d * 10 + n
let d0, d1, d2, d3, d4, d5, d6, d7, d8, d9 =
mkd 0, mkd 1, mkd 2, mkd 3, mkd 4, mkd 5, mkd 6, mkd 7, mkd 8, mkd 9

-- Brian

@vicuna
Copy link
Author

vicuna commented May 7, 2002

Comment author: administrator

File "pvmain.ml", line 4, characters 11-22:
The type of this expression, [ D2 of [ D3 of [ `U]]] Pvdim.dec,
contains type variables that cannot be generalized

There was indeed a small bug in the check for non-generalizable
variables for polymorphic variant types.
Thanks for your report, this is now corrected in CVS.

   Jacques

@vicuna
Copy link
Author

vicuna commented May 24, 2002

Comment author: administrator

Jacques Garrigue writes:

File "pvmain.ml", line 4, characters 11-22:
The type of this expression, [ D2 of [ D3 of [ `U]]] Pvdim.dec,
contains type variables that cannot be generalized

There was indeed a small bug in the check for non-generalizable
variables for polymorphic variant types.
Thanks for your report, this is now corrected in CVS.

   Jacques

I still get this error, only for x120 now instead of x32 (referring to the
original bug report). It all works fine from the top level. I am working
with

    Objective Caml version 3.04+11 (2002-05-16)

-- Brian

@vicuna
Copy link
Author

vicuna commented May 25, 2002

Comment author: administrator

Fixed by Jacques (2002-05-26)

@vicuna vicuna closed this as completed May 25, 2002
@vicuna
Copy link
Author

vicuna commented May 26, 2002

Comment author: administrator

From: Brian Rogoff bpr@artisan.com

Jacques Garrigue writes:

File "pvmain.ml", line 4, characters 11-22:
The type of this expression, [ D2 of [ D3 of [ `U]]] Pvdim.dec,
contains type variables that cannot be generalized

There was indeed a small bug in the check for non-generalizable
variables for polymorphic variant types.
Thanks for your report, this is now corrected in CVS.

I still get this error, only for x120 now instead of x32 (referring to the
original bug report). It all works fine from the top level. I am working
with

    Objective Caml version 3.04+11 (2002-05-16)

You're damn right. I'm pretty sure I checked at that time, but maybe some
subsequent change...
Anyway, the fix was incomplete. Now it should be okay. cvs update again!

Jacques

@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