From 727385d8534856e222b5e04a10dc8c7495f23fe9 Mon Sep 17 00:00:00 2001 From: Josh Berdine Date: Thu, 10 Oct 2019 06:17:35 -0700 Subject: [PATCH] [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 --- sledge/src/llair/typ.ml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/sledge/src/llair/typ.ml b/sledge/src/llair/typ.ml index 615cb94ed..f45d062cb 100644 --- a/sledge/src/llair/typ.ml +++ b/sledge/src/llair/typ.ml @@ -58,10 +58,9 @@ let pp_defn fs = function (** Invariants *) let is_sized = function - | Function _ | Opaque _ -> false + | Function _ -> false | Integer _ | Float _ | Pointer _ | Array _ | Tuple _ | Struct _ -> true - -let is_sized_or_opaque = function Opaque _ -> true | t -> is_sized t + | Opaque _ -> (* optimistically assume linking will make it sized *) true let invariant t = Invariant.invariant [%here] t [%sexp_of: t] @@ -70,9 +69,8 @@ let invariant t = | Function {return; args} -> assert (Option.for_all ~f:is_sized return) ; assert (Vector.for_all ~f:is_sized args) - | Array {elt} -> assert (is_sized_or_opaque elt) - | Tuple {elts} | Struct {elts} -> - assert (Vector.for_all ~f:is_sized_or_opaque elts) + | Array {elt} -> assert (is_sized elt) + | Tuple {elts} | Struct {elts} -> assert (Vector.for_all ~f:is_sized elts) | Integer {bits} | Float {bits} -> assert (bits > 0) | Pointer _ | Opaque _ -> assert true