You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 5821 Reporter:@mjambon Assigned to:@alainfrisch Status: closed (set by @xavierleroy on 2015-12-11T18:08:23Z) Resolution: fixed Priority: normal Severity: minor Version: 4.00.1 Fixed in version: 4.01.0+dev Category: typing Has duplicate:#5929
Bug description
When 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
The text was updated successfully, but these errors were encountered:
Original bug ID: 5821
Reporter: @mjambon
Assigned to: @alainfrisch
Status: closed (set by @xavierleroy on 2015-12-11T18:08:23Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 4.00.1
Fixed in version: 4.01.0+dev
Category: typing
Has duplicate: #5929
Bug description
When 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:
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
The text was updated successfully, but these errors were encountered: