aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler/src/beam_call_types.erl
diff options
context:
space:
mode:
authorJohn Högberg <[email protected]>2019-06-17 18:01:00 +0200
committerJohn Högberg <[email protected]>2019-07-05 11:33:38 +0200
commitbc321b89c38096a4a6148dccc41e2678d8e9feda (patch)
treef8614e747b10a439ca548cb1a1faa0ad6534e780 /lib/compiler/src/beam_call_types.erl
parenta10fb1edf471602be01bd5b4c1f019cc5534b9f5 (diff)
downloadotp-bc321b89c38096a4a6148dccc41e2678d8e9feda.tar.gz
otp-bc321b89c38096a4a6148dccc41e2678d8e9feda.tar.bz2
otp-bc321b89c38096a4a6148dccc41e2678d8e9feda.zip
compiler: Introduce union types
Consider the type `{ok, #record{}} | {error,atom()}`; in our current type representation this will be flattened down to `{ok | error, #record{} | atom()}`, which is fairly useful but has no connection between the elements. Testing that the first element is 'error' lets us skip checking that it's 'ok' on failure, but the second element is still `#record{} | atom()` and we'll eventually need to test that, even though it can only be a `#record{}`. Another example would be `false | {value, term()}`, the return value of lists:keyfind/3, which we're forced to flatten to `any` since there's nothing in common between an atom and a tuple. Union types let us express these types directly, greatly improving type optimization.
Diffstat (limited to 'lib/compiler/src/beam_call_types.erl')
-rw-r--r--lib/compiler/src/beam_call_types.erl2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/compiler/src/beam_call_types.erl b/lib/compiler/src/beam_call_types.erl
index 2aba6f7961..a94a7caa74 100644
--- a/lib/compiler/src/beam_call_types.erl
+++ b/lib/compiler/src/beam_call_types.erl
@@ -37,7 +37,7 @@
-spec types(Mod, Func, ArgTypes) -> {RetType, ArgTypes, CanSubtract} when
Mod :: atom(),
Func :: atom(),
- ArgTypes :: [type()],
+ ArgTypes :: [normal_type()],
RetType :: type(),
CanSubtract :: boolean().