Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Same name fields
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Mykola Stryebkov <nick@m...>
Subject: Same name fields

I'm trying to declare to record types with fields having the same name  
but different types.
Something like this:


type ta = { a : int; b : string }
type tb = { a : float; b : string list }

let f v = Printf.printf "%d\n" v.a


Compiler says I have an error in the line with Printf:
This expression has type float but is here used with type int

If I declare type ta second - everything works fine.
Is it a bug? If not, what is an appropriate workaround here?

Thanks in advance.

Mykola Stryebkov
Public key:
fpr: 0226 54EE C1FF 8636 36EF  2AC9 BCE9 CFC7 9CF4 6747