diff options
author | John Högberg <[email protected]> | 2019-06-17 18:01:00 +0200 |
---|---|---|
committer | John Högberg <[email protected]> | 2019-07-05 11:33:38 +0200 |
commit | bc321b89c38096a4a6148dccc41e2678d8e9feda (patch) | |
tree | f8614e747b10a439ca548cb1a1faa0ad6534e780 /lib/compiler/src/compile.erl | |
parent | a10fb1edf471602be01bd5b4c1f019cc5534b9f5 (diff) | |
download | otp-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/compile.erl')
0 files changed, 0 insertions, 0 deletions