English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

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: 2009-11-21 (15:33)
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
Blog: http://mykola.org/blog/
Public key: http://mykola.org/pubkey.txt
fpr: 0226 54EE C1FF 8636 36EF  2AC9 BCE9 CFC7 9CF4 6747