* [Caml-list] Odd type error reporting
@ 2016-06-15 7:37 Christoph Höger
2016-06-15 8:52 ` Leo White
0 siblings, 1 reply; 3+ messages in thread
From: Christoph Höger @ 2016-06-15 7:37 UTC (permalink / raw)
To: caml users
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] Odd type error reporting
2016-06-15 7:37 [Caml-list] Odd type error reporting Christoph Höger
@ 2016-06-15 8:52 ` Leo White
2016-06-15 9:20 ` octachron
0 siblings, 1 reply; 3+ messages in thread
From: Leo White @ 2016-06-15 8:52 UTC (permalink / raw)
To: caml-list
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] Odd type error reporting
2016-06-15 8:52 ` Leo White
@ 2016-06-15 9:20 ` octachron
0 siblings, 0 replies; 3+ messages in thread
From: octachron @ 2016-06-15 9:20 UTC (permalink / raw)
To: caml-list
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-06-15 9:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-15 7:37 [Caml-list] Odd type error reporting Christoph Höger
2016-06-15 8:52 ` Leo White
2016-06-15 9:20 ` octachron
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox