Data_encoding: skip zero_width field in binary description

This commit is contained in:
Grégoire Henry 2018-05-31 12:42:05 +02:00 committed by Benjamin Canou
parent 7c2ef081d5
commit 6922a793fe

View File

@ -157,6 +157,9 @@ let describe (type x) ?toplevel_name (encoding : x Encoding.t) =
| Dft { name ; encoding = { encoding } } ->
let (dynamics, ref_name, P field) = extract_dynamic None encoding in
let (layout, references) = layout ref_name recursives references field in
if layout = Zero_width && dynamics then
([], references) (* FIXME what if (dynamic_size empty) ?? *)
else
let field_descr =
Binary_schema.Named_field (name, classify_desc field, layout) in
if dynamics then
@ -274,6 +277,9 @@ let describe (type x) ?toplevel_name (encoding : x Encoding.t) =
| Tup { encoding } ->
let (layout, references) =
layout ref_name recursives references encoding in
if layout = Zero_width then
([], references)
else
([ Anonymous_field (classify_desc encoding, layout) ], references)
| Tups { left ; right } ->
let (fields1, references) =