Version française
Home     About     Download     Resources     Contact us    
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
Hi,

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