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

Inverted pattern unification error #6849

Closed
vicuna opened this issue Apr 27, 2015 · 4 comments
Closed

Inverted pattern unification error #6849

vicuna opened this issue Apr 27, 2015 · 4 comments
Assignees
Milestone

Comments

@vicuna
Copy link

vicuna commented Apr 27, 2015

Original bug ID: 6849
Reporter: @lpw25
Assigned to: @garrigue
Status: closed (set by @xavierleroy on 2016-12-07T10:49:12Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 4.02.1
Target version: 4.02.2+dev / +rc1
Fixed in version: 4.02.2+dev / +rc1
Category: typing
Monitored by: @hcarty

Bug description

The following code:

type 'a t = Foo : int t

let f : int -> int = function
Foo -> 5;;

produces the following error:

Characters 34-37:
    Foo -> 5;;
    ^^^

Error: This pattern matches values of type int
but a pattern was expected which matches values of type 'a t

The types should of course be the other way around.

@vicuna
Copy link
Author

vicuna commented Apr 27, 2015

Comment author: @gasche

That looks like a programming mistake to me, because your (int -> int) annotation is wrong, you should write (int t -> int) or drop it altogether as the compiler can infer it.

@vicuna
Copy link
Author

vicuna commented Apr 27, 2015

Comment author: @lpw25

The code is nonsense. I just wanted a small repro case to illustrate that somewhere one of the calls to unify is back-to-front.

@vicuna
Copy link
Author

vicuna commented Apr 27, 2015

Comment author: @gasche

Ah, of course: the error message should read

Error: This pattern matches values of type 'a t
but a pattern was expected which matches values of type int

Sorry for the noise.

@vicuna
Copy link
Author

vicuna commented May 6, 2015

Comment author: @garrigue

Fixed in 4.02 at revision 16088.

@vicuna vicuna closed this as completed Dec 7, 2016
@vicuna vicuna added the typing label Mar 14, 2019
@vicuna vicuna added this to the 4.02.2 milestone Mar 14, 2019
@vicuna vicuna added the bug label Mar 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants