Skip to content

Commit 85f35ce

Browse files
committed
Restoring dependency error messages
1 parent be7b2c6 commit 85f35ce

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

src/ecLowCircuits.ml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1326,7 +1326,7 @@ module MakeCircuitInterfaceFromCBackend(Backend: CBackend) : CircuitInterface =
13261326
| -> When lane dependency description does not fit circuit
13271327
*)
13281328
let general_decompose ((`CBitstring r, inps) as c: cbitstring cfun) (lanes: ((int list) * (int Set.t)) list): cbitstring cfun list =
1329-
1329+
let exception DependencyError in
13301330
(* Check that outputs cover the circuit *)
13311331
let outputs = List.fst lanes |> List.flatten |> List.sort (Int.compare) in
13321332
assert (List.for_all2 (fun a b -> a = b) outputs (List.init (List.length outputs) (fun i -> i)));
@@ -1339,9 +1339,9 @@ module MakeCircuitInterfaceFromCBackend(Backend: CBackend) : CircuitInterface =
13391339
(* Separate one lane *)
13401340
let doit ((outputs, inputs): int list * int Set.t) : cbitstring cfun =
13411341
let c = Backend.subcirc r outputs in
1342-
assert (Backend.Deps.forall_inputs (fun id b ->
1342+
if not @@ Backend.Deps.forall_inputs (fun id b ->
13431343
input.id = id &&
1344-
Set.mem b inputs) c);
1344+
Set.mem b inputs) c then raise DependencyError;
13451345
let _, new_inp = new_cbitstring_inp (Set.cardinal inputs) in
13461346
let bit_renames = List.mapi (fun i b -> (b, i)) (Set.to_list inputs) in
13471347
let bit_renamer = Map.of_seq (List.to_seq bit_renames) in
@@ -1351,7 +1351,13 @@ module MakeCircuitInterfaceFromCBackend(Backend: CBackend) : CircuitInterface =
13511351
else None
13521352
in `CBitstring (Backend.Deps.rename_inputs renamer c), [new_inp]
13531353
in
1354-
List.map doit lanes
1354+
try List.map doit lanes
1355+
with DependencyError ->
1356+
(* FIXME: hack *)
1357+
let w = List.length (List.hd lanes |> fst) in
1358+
let d = Backend.Deps.block_deps_of_reg w r in
1359+
Format.eprintf "Dependencies:@.%a@." Backend.Deps.pp_block_deps d;
1360+
raise (CircError "Dep check fail")
13551361

13561362
let decompose (in_w: width) (out_w: width) ((`CBitstring r, inps) as c: cbitstring cfun) : cbitstring cfun list =
13571363
let n = Backend.size_of_reg r in

0 commit comments

Comments
 (0)