caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Tim Leonard <Tim@TimLeonard.us>
To: caml-list@inria.fr
Subject: [Caml-list] type inference of record field that is an array
Date: Tue, 16 May 2017 12:58:14 -0400	[thread overview]
Message-ID: <C370B8CA-66DD-4635-A26D-AF12126C5552@TimLeonard.us> (raw)

[-- 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 --]

             reply	other threads:[~2017-05-16 16:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-16 16:58 Tim Leonard [this message]
2017-05-16 17:05 ` Ivan Gotovchits

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=C370B8CA-66DD-4635-A26D-AF12126C5552@TimLeonard.us \
    --to=tim@timleonard.us \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).