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: 6171 Reporter:@johnwhitington Assigned to:@garrigue Status: closed (set by @xavierleroy on 2016-12-07T10:47:07Z) Resolution: fixed Priority: normal Severity: minor Version: 4.01.0+beta/+rc Target version: 4.02.2+dev / +rc1 Fixed in version: 4.03.0+dev / +beta1 Category: typing Has duplicate:#6734 Monitored by:@bobzhang@gasche@hcarty
Bug description
I'd only had to deal with this error when using the module system until now -- I hadn't realised how easily it could be encountered with a single reference.
The first line of the message in particular is rather confusing:
let x = ref []
type t = A
let store () =
x := A::!x
feast:~ john$ ocamlc mess.ml
File "mess.ml", line 6, characters 7-8:
Error: This expression has type t but an expression was expected of type t
The type constructor t would escape its scope
Perhaps skip the first line of the error message since it's confusing and add a clarification -- something like "A type can only be used after it has been introduced."?
The text was updated successfully, but these errors were encountered:
Reporting of unification errors is fundamentally broken: it is hard to see where the error comes from, and specific cases are poorly handled.
I hope to be able to fix it, but this would need some deep changes.
Quick fixes do not help much.
For instance here, if we remove the first line, we lose the type of the expression, which can be informative.
It wouldn't help much in this case, but could the error at least mention the type that it tried to unify t with, rather than t itself.
So, for example:
# let f b (x: 'x) =
let module M = struct
type t = A
end in
if b then x else M.A;;
Characters 96-99:
if b then x else M.A;;
^^^
Error: This expression has type M.t but an expression was expected of type
'x
The type constructor M.t would escape its scope
This information is often quite useful, and I don't think it would be hard to expose.
Original bug ID: 6171
Reporter: @johnwhitington
Assigned to: @garrigue
Status: closed (set by @xavierleroy on 2016-12-07T10:47:07Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 4.01.0+beta/+rc
Target version: 4.02.2+dev / +rc1
Fixed in version: 4.03.0+dev / +beta1
Category: typing
Has duplicate: #6734
Monitored by: @bobzhang @gasche @hcarty
Bug description
I'd only had to deal with this error when using the module system until now -- I hadn't realised how easily it could be encountered with a single reference.
The first line of the message in particular is rather confusing:
let x = ref []
type t = A
let store () =
x := A::!x
feast:~ john$ ocamlc mess.ml
File "mess.ml", line 6, characters 7-8:
Error: This expression has type t but an expression was expected of type t
The type constructor t would escape its scope
Perhaps skip the first line of the error message since it's confusing and add a clarification -- something like "A type can only be used after it has been introduced."?
The text was updated successfully, but these errors were encountered: