Skip to content

Commit

Permalink
Fix very nested bitstring types
Browse files Browse the repository at this point in the history
  • Loading branch information
NelsonVides committed Oct 12, 2019
1 parent 38ca950 commit 7bbc7f9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 1 addition & 2 deletions src/typechecker.erl
Original file line number Diff line number Diff line change
Expand Up @@ -2308,8 +2308,7 @@ do_type_check_expr_in(Env, ResTy, {bc, P, Expr, Qualifiers}) ->
case catch {type_check_comprehension_in(Env, FlatTy, bc, Expr, P, Qualifiers), Acc} of
{{#{}, C1}, {#{}, C2}} -> {ok, {#{}, constraints:combine(C1, C2)}};
{{#{}, _} = C, {type_error, _, _, _}} -> {ok, C};
{type_error, bc, P, FlatTy} -> {type_error,Acc};
{type_error, _, _, _} = E -> throw(E)
{type_error, _, _, FlatTy} -> {type_error,Acc}
end
end, Error, flatten_type(ResTy, Env)),
lists:any(fun(El) -> El =:= ok end, Res) orelse throw(Error),
Expand Down
8 changes: 7 additions & 1 deletion test/should_pass/binary_in_union.erl
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
-module(binary_in_union).
-export([
iodata_binary/0,
bitstring_fun/0
bitstring_fun/0,
nested_bitstrings/0
]).

-spec iodata_binary() -> iodata().
Expand All @@ -11,3 +12,8 @@ iodata_binary() ->
-spec bitstring_fun() -> <<_:7, _:_*3>> | string().
bitstring_fun() ->
<< <<1:N>> || N <- lists:seq(3, 12)>>.

-type nested() :: string() | bitstring() | binary().
-spec nested_bitstrings() -> nested() | boolean() | bitstring().
nested_bitstrings() ->
<< <<1:N>> || N <- lists:seq(1, 12)>>.

0 comments on commit 7bbc7f9

Please sign in to comment.