Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong record field is reported as duplicate #5821

Closed
vicuna opened this Issue Nov 13, 2012 · 1 comment

Comments

Projects
None yet
2 participants
@vicuna
Copy link
Collaborator

vicuna commented Nov 13, 2012

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

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Nov 14, 2012

Comment author: @alainfrisch

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.