Skip to content

Commit

Permalink
[hack] Grow shapes more correctly
Browse files Browse the repository at this point in the history
Summary: Just copying the type from value to field might propagate it to places where it ends up unifying with things it shouldn't.

Instead, we can set it to a new type variable and let the existing code for assignment bind it (using sub_type).

Reviewed By: @dlreeves

Differential Revision: D2202779
  • Loading branch information
dabek authored and facebook-github-bot-2 committed Jul 17, 2015
1 parent ba11b86 commit e4a620d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions hack/typing/typing.ml
Expand Up @@ -1782,12 +1782,13 @@ and assign p env e1 ty2 =
let env, shape_ty = expr env shape in
let field = TUtils.shape_field_name p1 e in
let env, shape_ty =
Typing_shapes.grow_shape p e1 field ty2 env shape_ty in
Typing_shapes.grow_shape p e1 field (Env.fresh_type()) env shape_ty in
let env, _ty = set_valid_rvalue p env lvar shape_ty in

(* We still need to call assign_simple, because shape_ty could be more
* than just a shape. It could be an unresolved type where some elements
* are shapes and some others are not.
(* We still need to call assign_simple in order to bind the freshly
* created variable in added shape field. Moreover, it's needed because
* shape_ty could be more than just a shape. It could be an unresolved
* type where some elements are shapes and some others are not.
*)
assign_simple p env e1 ty2
| _, This ->
Expand Down

0 comments on commit e4a620d

Please sign in to comment.