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
Comments
Comment author: administrator
There was indeed a small bug in the check for non-generalizable
|
Comment author: administrator Jacques Garrigue writes:
I still get this error, only for x120 now instead of x32 (referring to the
-- Brian |
Comment author: administrator Fixed by Jacques (2002-05-26) |
Comment author: administrator From: Brian Rogoff bpr@artisan.com
You're damn right. I'm pretty sure I checked at that time, but maybe some Jacques |
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.
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] decval d2 : 'a dec -> [
D2 of 'a] dec val d3 : 'a dec -> [
D3 of 'a] decval d4 : 'a dec -> [
D4 of 'a] dec val d5 : 'a dec -> [
D5 of 'a] decval d6 : 'a dec -> [
D6 of 'a] dec val d7 : 'a dec -> [
D7 of 'a] decval 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
The text was updated successfully, but these errors were encountered: