caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: octachron <octa@polychoron.fr>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Odd type error reporting
Date: Wed, 15 Jun 2016 11:20:56 +0200	[thread overview]
Message-ID: <87b025f9-4d31-192e-15ad-1b26c5bde5ba@polychoron.fr> (raw)
In-Reply-To: <1465980742.269779.638209889.162FFE6E@webmail.messagingengine.com>

The mantis ticket might be this one:

http://caml.inria.fr/mantis/view.php?id=6931

Regards,
octachron.

Le 06/15/16 à 10:52, Leo White a écrit :
> This bug was fixed in 4.03.0:
>
>    Characters 29-32:
>    let () = { f = fun bar -> { bar } };;
>                                ^^^
> Error: This record expression is expected to have type foo
>         The field bar does not belong to type foo
>
> I vaguely remember a mantis about this (or a similar issue) and that
> it was resolved, but I don't have its PR number to hand.
>
> Regards,
>
> Leo
>
> On Wed, 15 Jun 2016, at 03:37 AM, Christoph Höger wrote:
>> Dear all,
>>
>> It just took me 30min to figure out a rather simple type-error in my
>> code. It was complicated by ocamlc's strange error reporting. Consider
>> this example:
>>
>> % cat error.ml
>> type foo = { foo : int }
>> type bar = { bar : int }
>> type baz = { f : int -> foo }
>>
>> let () = { f = fun bar -> { bar } }
>> % ocamlc error.ml
>> File "error.ml", line 5, characters 28-31:
>> Error: This record expression is expected to have type baz
>>         The field bar does not belong to type foo
>>
>>
>>
>> ocamlc correctly spots the "bar" in the last line as the source of the
>> error. However, it says, it is expected to have type "baz", but that is
>> the surrounding constructor.
>>
>> In fact, the "correct" error is:
>>
>> File "error.ml", line 5, characters 26-33:
>> Error: This record expression is expected to have type foo
>>         The field bar does not belong to type foo
>>
>>
>>
>> Obviously, in a perfect world, the wrongly labeled field should be
>> pointed out as well (kind of a sub-error). However, it seems problematic
>> that the outermost record-mismatch is reported.
>>
>> Is this a known bug/feature? Does it change in later versions (I am on
>> 4.02.3 now)?
>>
>> thanks,
>>
>> Christoph
>> -- 
>> Christoph Höger
>>
>> Technische Universität Berlin
>> Fakultät IV - Elektrotechnik und Informatik
>> Übersetzerbau und Programmiersprachen
>>
>> Sekr. TEL12-2, Ernst-Reuter-Platz 7, 10587 Berlin
>>
>> Tel.: +49 (30) 314-24890
>> E-Mail: christoph.hoeger@tu-berlin.de
>>
>> -- 
>> Caml-list mailing list.  Subscription management and archives:
>> https://sympa.inria.fr/sympa/arc/caml-list
>> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
>> Bug reports: http://caml.inria.fr/bin/caml-bugs


      reply	other threads:[~2016-06-15  9:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-15  7:37 Christoph Höger
2016-06-15  8:52 ` Leo White
2016-06-15  9:20   ` octachron [this message]

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=87b025f9-4d31-192e-15ad-1b26c5bde5ba@polychoron.fr \
    --to=octa@polychoron.fr \
    --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).