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: 6303 Reporter:@alainfrisch Assigned to:@garrigue Status: closed (set by @xavierleroy on 2015-12-11T18:25:37Z) Resolution: fixed Priority: normal Severity: major Fixed in version: 4.02.0+dev Category: typing Monitored by:@gasche@jmeber@hcarty
Bug description
On trunk, it seems that an expression {e with x = ...} does not propagate type constraints from x to the record type. The following code segfaults:
type 'a foo = {x: 'a; y: int}
let r = {{x = 0; y = 0} with x = 0}
let () = print_endline (r.x ^ "")
The type inferred for [r] is a polymorphic ['a foo], instead of [int foo].
The text was updated successfully, but these errors were encountered:
Introduced by commit 14166, and more precisely this change:
let op =
match opt_exp with
None -> None
| Some exp -> get_path exp.exp_type
in
newvar (), op
---->
begin match opt_exp with
None -> newvar (), None
| Some exp ->
match get_path exp.exp_type with
None -> newvar (), None
| Some (_, p', _) as op ->
let decl = Env.find_type p' env in
begin_def ();
let ty =
newconstr p' (instance_list env decl.type_params) in
end_def ();
generalize ty;
ty, op
end
Removing the call to [generalize] seems to solve the issue. Jacques: is it a correct fix?
Original bug ID: 6303
Reporter: @alainfrisch
Assigned to: @garrigue
Status: closed (set by @xavierleroy on 2015-12-11T18:25:37Z)
Resolution: fixed
Priority: normal
Severity: major
Fixed in version: 4.02.0+dev
Category: typing
Monitored by: @gasche @jmeber @hcarty
Bug description
On trunk, it seems that an expression {e with x = ...} does not propagate type constraints from x to the record type. The following code segfaults:
type 'a foo = {x: 'a; y: int}
let r = {{x = 0; y = 0} with x = 0}
let () = print_endline (r.x ^ "")
The type inferred for [r] is a polymorphic ['a foo], instead of [int foo].
The text was updated successfully, but these errors were encountered: