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

The same string can mean different types in the same error message #6416

Closed
vicuna opened this issue May 12, 2014 · 4 comments

Comments

Projects
None yet
2 participants
@vicuna
Copy link

commented May 12, 2014

Original bug ID: 6416
Reporter: dwang
Assigned to: @Octachron
Status: resolved (set by @Octachron on 2018-06-26T20:19:28Z)
Resolution: fixed
Priority: normal
Severity: minor
Platform: x86 64-bit
OS: Linux CentOS 6
OS Version: 2.6.32-358.23.2.
Version: 4.01.0
Fixed in version: 4.08.0+dev/beta1/beta2
Category: typing
Related to: #4791
Monitored by: @gasche

Bug description

Compile this code:

module M = struct
type t = A
module M : sig
val f : t -> unit
end = struct
type t = B
let f B = ()
end
end

The error is

Values do not match: val f : t -> unit is not included in val f : t -> unit
Line 4, characters 4-21: Expected declaration
Line 7, characters 8-9: Actual declaration

I would prefer the error to be more explicit that there are two
different types here both named 't'.

Steps to reproduce

Compile this code:

module M = struct
type t = A
module M : sig
val f : t -> unit
end = struct
type t = B
let f B = ()
end
end

@vicuna

This comment has been minimized.

Copy link
Author

commented May 30, 2014

Comment author: @mshinwell

I think this is a fairly long-standing problem, which we should look at after 4.02.

@vicuna

This comment has been minimized.

Copy link
Author

commented May 31, 2014

Comment author: @garrigue

As a side note, this problem is already solved for unification errors: in that case, the internal id for each type is printed. This is not done yet for module coercion errors, but shouldn't be more difficult.

@vicuna

This comment has been minimized.

Copy link
Author

commented Mar 23, 2017

Comment author: @Octachron

I have a proposition to extend the mechanism used for unification errors to print unambiguous identifier names in various error and warning messages in the PR #1120 .

@vicuna

This comment has been minimized.

Copy link
Author

commented Jun 26, 2018

Comment author: @Octachron

After the merge of the PR above in 4.08, the error message identifies now the different types t and print if possible the location of their definition:

   Values do not match:
     val f : t/1 -> unit
   is not included in
     val f : t/2 -> unit
   File "...", line 5, characters 4-21: Expected declaration
   File "...", line 8, characters 8-9: Actual declaration
   File "...", line 7, characters 4-14:
     Definition of type t/1
   File "...", line 3, characters 2-12:
     Definition of type t/2
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.