-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix the bitstring subtype generic case
If the return type of a function returning a binary comprehension is a supertype of a bitstring, we want the function to match correctly. While before I had fixed a special case (binary), when fixing a deeper case with nested unions and arbitrary bitstring sizes, it turned out to be better to expand the union and try to typecheck against any of them. So on the return of `flatten_type(ResTy, Env)` we try to typecheck the binary comprehension. If it does, then we have a match, and we merge into it the constraints that any possible match on subsequent flattened types might give. If it returns the specific error, we ignore it, if it returns a different one, not related to the fact that we're trying to match on subtypes, we crash.
- Loading branch information
1 parent
cd9d8ca
commit 38ca950
Showing
2 changed files
with
21 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,13 @@ | ||
-module(binary_in_union). | ||
-export([iodata_binary/0]). | ||
-export([ | ||
iodata_binary/0, | ||
bitstring_fun/0 | ||
]). | ||
|
||
-spec iodata_binary() -> iodata(). | ||
iodata_binary() -> | ||
<<<<"A">> || _ <- lists:seq(1, 10)>>. | ||
|
||
-spec bitstring_fun() -> <<_:7, _:_*3>> | string(). | ||
bitstring_fun() -> | ||
<< <<1:N>> || N <- lists:seq(3, 12)>>. |