Skip to content

Commit 2f9b86f

Browse files
committed
feat twine.decode: allow arrays/records/cstors to have excess elts
this makes it possible to add arguments at the end of a record or tuple or constructor and decode it with the old type.
1 parent 7f208c8 commit 2f9b86f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/twine/ppx/imandrakit_twine_ppx.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ let decode_expr_of_tydecl (decl : type_declaration) : expression =
497497
[%pat? Imandrakit_twine.Decode.Value.CstorN ([%p p_index], args)]
498498
in
499499
let guard =
500-
[%expr Imandrakit_twine.Decode.Array_cursor.length args = 1]
500+
[%expr Imandrakit_twine.Decode.Array_cursor.length args >= 1]
501501
in
502502
let rhs =
503503
[%expr
@@ -516,7 +516,7 @@ let decode_expr_of_tydecl (decl : type_declaration) : expression =
516516
let guard =
517517
let arity = A.Exp.constant (A.Const.int @@ List.length l) in
518518
[%expr
519-
Imandrakit_twine.Decode.Array_cursor.length args = [%e arity]]
519+
Imandrakit_twine.Decode.Array_cursor.length args >= [%e arity]]
520520
in
521521
let vars, read_args = read_cstor_args l in
522522
let rhs =
@@ -533,7 +533,7 @@ let decode_expr_of_tydecl (decl : type_declaration) : expression =
533533
let guard =
534534
let arity = A.Exp.constant (A.Const.int @@ List.length r) in
535535
[%expr
536-
Imandrakit_twine.Decode.Array_cursor.length args = [%e arity]]
536+
Imandrakit_twine.Decode.Array_cursor.length args >= [%e arity]]
537537
in
538538
let rhs =
539539
let vars, read_args =

0 commit comments

Comments
 (0)