caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] type inference of record field that is an array
@ 2017-05-16 16:58 Tim Leonard
  2017-05-16 17:05 ` Ivan Gotovchits
  0 siblings, 1 reply; 2+ messages in thread
From: Tim Leonard @ 2017-05-16 16:58 UTC (permalink / raw)
  To: caml-list

[-- Attachment #1: Type: text/plain, Size: 708 bytes --]

Is type inference working as expected here, or is this a bug?

# type record_type = { array_field : int array };;
type record_type = { array_field : int array; }
# let test_function_1 x = Array.set x.array_field 1 3;;
val test_function_1 : record_type -> unit = <fun>
# let test_function_2 x = x.array_field.[1] <- 3;;
Characters 24-46:
  let test_function_2 x = x.array_field.[1] <- 3;;
                          ^^^^^^^^^^^^^^^^^^^^^^
Warning 3: deprecated: String.set
Use Bytes.set instead.
Characters 24-37:
  let test_function_2 x = x.array_field.[1] <- 3;;
                          ^^^^^^^^^^^^^
Error: This expression has type int array
       but an expression was expected of type bytes = string
# 

[-- Attachment #2: Type: text/html, Size: 2157 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-05-16 17:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-16 16:58 [Caml-list] type inference of record field that is an array Tim Leonard
2017-05-16 17:05 ` Ivan Gotovchits

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).