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

Explicit coercion in value bindings does not work in OCaml 5.1.0~alpha1 #12188

Closed
kit-ty-kate opened this issue Apr 17, 2023 · 1 comment · Fixed by #12191
Closed

Explicit coercion in value bindings does not work in OCaml 5.1.0~alpha1 #12188

kit-ty-kate opened this issue Apr 17, 2023 · 1 comment · Fixed by #12191
Milestone

Comments

@kit-ty-kate
Copy link
Member

let x : [`A | `B] = `A

let y : [`A | `B] :> [`A | `B | `C] = x

compiles just fine with OCaml 5.0.0 but fails with OCaml 5.1.0~alpha1 with:

File "test.ml", line 3, characters 38-39:
3 | let y : [`A | `B] :> [`A | `B | `C] = x
                                          ^
Error: This expression has type [ `A | `B ]
       but an expression was expected of type [ `A | `B | `C ]
       The first variant type does not allow tag(s) `C

This behaviour can only be observed when the coercion is in the binding. When it is in the expression section it works fine:

let y = (x : [`A | `B] :> [`A | `B | `C])
@Octachron Octachron modified the milestones: 5.0.1, 5.1 Apr 17, 2023
@Octachron
Copy link
Member

This is a bug in #12119: I didn't catch the fact that coercions are allowed on value binding. I will have a fix shortly, and since it requires an update to the parsetree, I will publish another alpha to try to stabilize the intermediary representation during the alpha releases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants