Skip to content

Commit

Permalink
Allow option types in union members.
Browse files Browse the repository at this point in the history
  • Loading branch information
skrah committed May 8, 2019
1 parent 7a8dde2 commit c3c6067
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
6 changes: 0 additions & 6 deletions libndtypes/ndtypes.c
Original file line number Diff line number Diff line change
Expand Up @@ -2018,12 +2018,6 @@ init_concrete_tags(ndt_t *t, const ndt_field_t *fields, int64_t ntags,
return -1;
}

if (fields[i].type->flags & (NDT_OPTION|NDT_SUBTREE_OPTION)) {
ndt_err_format(ctx, NDT_NotImplementedError,
"union member types cannot be optional");
return -1;
}

maxsize = max_i64(fields[i].type->datasize, maxsize);
}

Expand Down
4 changes: 4 additions & 0 deletions libndtypes/tests/test_unify.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ const unify_testcase_t unify_tests[] = {
"2 * 3 * [Int of int8 | Something of {foo: complex128, bar: Any}]",
"2 * 3 * [Int of int8 | Something of {foo: complex128, bar: string}]" },

{ "2 * 3 * [Int of int8 | Something of {foo: ?Any, bar: string}]",
"2 * 3 * [Int of int8 | Something of {foo: complex128, bar: ?Any}]",
"2 * 3 * [Int of int8 | Something of {foo: ?complex128, bar: ?string}]" },

{ "var(offsets=[0,2]) * (int8, {foo: complex64, bar: string})",
"var(offsets=[0,3]) * (int8, {foo: complex128, bar: string})",
NULL },
Expand Down

0 comments on commit c3c6067

Please sign in to comment.