Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0005821OCamlOCaml typingpublic2012-11-13 20:072012-11-14 18:01
ReporterMartin Jambon 
Assigned Tofrisch 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
PlatformOSOS Version
Product Version4.00.1 
Target VersionFixed in Version4.01.0+dev 
Summary0005821: Wrong record field is reported as duplicate
DescriptionWhen a record field in an expression is defined twice by mistake, the error message reports another field as duplicated. It is confusing and can take a long time to figure out when the record has many fields (we routinely use records of more than 20 fields).

The problem exists with ocaml 4.00.0 and 4.00.1. Not sure when it started.

Here are some examples where the wrong field is reported:

        OCaml version 4.00.1

type t = { a : int; b : int; c : int };;
# type t = { a : int; b : int; c : int; }
# let a, b, c = 1, 2, 3;;
val a : int = 1
val b : int = 2
val c : int = 3
# let x = { a = 1; b; c = 3; b = 4 };;
Characters 8-34:
  let x = { a = 1; b; c = 3; b = 4 };;
          ^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: The record field label c is defined several times

# let y = { a = 1; b; c; b = 4 };;
Characters 8-30:
  let y = { a = 1; b; c; b = 4 };;
          ^^^^^^^^^^^^^^^^^^^^^^
Error: The record field label c is defined several times

# let z = { a; b; c; b };;
Characters 8-22:
  let z = { a; b; c; b };;
          ^^^^^^^^^^^^^^
Error: The record field label c is defined several times

# let t = { a = 0; b = 0; c = 0; b = 0 };;
Characters 8-38:
  let t = { a = 0; b = 0; c = 0; b = 0 };;
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: The record field label c is defined several times


The reported field seems to be off by one, as shown in this longer example:

type long = {
  a : int;
  b : int;
  c : int;
  d : int;
  e : int;
  f : int;
  g : int;
  h : int;
  i : int;
  j : int;
}
;;

let x = {
  a = 0;
  b = 0;
  c = 0;
  d = 0;
  e = 0;
  f = 0;
  g = 0;
  h = 0;
  i = 0;
  e = 0;
  j = 0;
}
;;
Error: The record field label f is defined several times
TagsNo tags attached.
Attached Files

- Relationships
has duplicate 0005929resolvedfrisch The error "label defined several times" complains about the wrong label 

-  Notes
(0008512)
frisch (developer)
2012-11-14 18:00

Thanks! This is now fixed in trunk (commit 13093).

- Issue History
Date Modified Username Field Change
2012-11-13 20:07 Martin Jambon New Issue
2012-11-14 17:51 frisch Assigned To => frisch
2012-11-14 17:51 frisch Status new => assigned
2012-11-14 18:00 frisch Note Added: 0008512
2012-11-14 18:01 frisch Status assigned => resolved
2012-11-14 18:01 frisch Fixed in Version => 4.01.0+dev
2012-11-14 18:01 frisch Resolution open => fixed
2013-02-22 10:02 frisch Relationship added has duplicate 0005929


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker