Browse thread
strange behavior with record type definition
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Florent <florentflament@a...> |
| Subject: | Re: [Caml-list] strange behavior with record type definition |
Ok but with these two record types defined :
type t0 = { x : int ; y : int } ;;
type t1 = { x : int } ;;
There is no ambiguity about the following expression's type:
{ x = 0 ; y = 0 } ;;
Why can't the t0 type be infered ?
And with this function definition,
let get_y (t:t0) = t.x ;;
I explicitly say to the compiler that t is of type t0, so why does the
compiler infer a t1 type when trying to get the x label of a t0 type value ?
Matthieur Dubuget wrote :
> If there is y.x in your code, and the type t = {x : blabla; ...} was
> declared,
> then y's type is infered to be of type t
Skaller wrote :
> So that the type of an expression:
> { x = 1; y = 2 }
> can be determined.