[sledge] Relax Typ.is_sized to allow opaque types

Summary:
Linking can lead to opaque types becoming identified with a known
types. Assertions in various places that types should be sized can be
triggered by such opaque types. Until there is a distinction between
processing fully-linked versus incomplete code, these checks need to
be relaxed to permit opaque types where sized ones are expected.

Reviewed By: bennostein

Differential Revision: D17801929

fbshipit-source-id: c5e62f7c8
master
Josh Berdine 5 years ago committed by Facebook Github Bot
parent f804220cd2
commit 727385d853

@ -58,10 +58,9 @@ let pp_defn fs = function
(** Invariants *) (** Invariants *)
let is_sized = function let is_sized = function
| Function _ | Opaque _ -> false | Function _ -> false
| Integer _ | Float _ | Pointer _ | Array _ | Tuple _ | Struct _ -> true | Integer _ | Float _ | Pointer _ | Array _ | Tuple _ | Struct _ -> true
| Opaque _ -> (* optimistically assume linking will make it sized *) true
let is_sized_or_opaque = function Opaque _ -> true | t -> is_sized t
let invariant t = let invariant t =
Invariant.invariant [%here] t [%sexp_of: t] Invariant.invariant [%here] t [%sexp_of: t]
@ -70,9 +69,8 @@ let invariant t =
| Function {return; args} -> | Function {return; args} ->
assert (Option.for_all ~f:is_sized return) ; assert (Option.for_all ~f:is_sized return) ;
assert (Vector.for_all ~f:is_sized args) assert (Vector.for_all ~f:is_sized args)
| Array {elt} -> assert (is_sized_or_opaque elt) | Array {elt} -> assert (is_sized elt)
| Tuple {elts} | Struct {elts} -> | Tuple {elts} | Struct {elts} -> assert (Vector.for_all ~f:is_sized elts)
assert (Vector.for_all ~f:is_sized_or_opaque elts)
| Integer {bits} | Float {bits} -> assert (bits > 0) | Integer {bits} | Float {bits} -> assert (bits > 0)
| Pointer _ | Opaque _ -> assert true | Pointer _ | Opaque _ -> assert true

Loading…
Cancel
Save