Skip to content

Commit b185234

Browse files
committed
Indivisible -> Broad
1 parent 1018f3c commit b185234

4 files changed

Lines changed: 17 additions & 8 deletions

File tree

lib/elixir/lib/module/types/descr.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2371,7 +2371,7 @@ defmodule Module.Types.Descr do
23712371

23722372
defp indivisible_bitmap(descr, opts) do
23732373
with true <- Keyword.get(opts, :skip_dynamic_for_indivisible, true),
2374-
%{bitmap: bitmap} when map_size(descr) == 1 <- descr,
2374+
%{bitmap: bitmap} when map_size(descr) == 1 and bitmap != @bit_bitstring <- descr,
23752375
[single] <- bitmap_to_quoted(bitmap) do
23762376
single
23772377
else

lib/elixir/pages/cheatsheets/types-cheat.cheatmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ not type
3333

3434
## Data types
3535

36-
### Indivisible types
36+
### Broad types
3737

3838
```elixir
3939
bitstring()

lib/elixir/pages/references/gradual-set-theoretic-types.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,13 @@ You can find a complete reference in the [set-theoretic types cheatsheet](../che
5555

5656
In this section we will cover the syntax of all data types. At the moment, developers will interact with those types mostly through compiler warnings and diagnostics.
5757

58-
### Indivisible types
58+
### Broad types
5959

60-
These types are indivisibile and have no further representation. They are: `binary()`, `bitstring()`, `integer()`, `float()`, `pid()`, `port()`, `reference()`. For example, the numbers `1` and `42` are both represented by the type `integer()`.
60+
These types are broad in that they cannot represent individual elements, only the whole set. For example, the numbers `1` and `42` are both represented by the type `integer()`.
6161

62-
Note the `binary()` type is a subtype of the less frequently used `bitstring()` type, as binaries are bitstrings where the number of bits is divisible by 8.
62+
They are: `binary()`, `bitstring()`, `integer()`, `float()`, `pid()`, `port()`, `reference()`.
63+
64+
The `binary()` type is a subtype of the less frequently used `bitstring()` type, as binaries are bitstrings where the number of bits is divisible by 8.
6365

6466
### Atoms
6567

lib/elixir/test/elixir/module/types/descr_test.exs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2528,16 +2528,23 @@ defmodule Module.Types.DescrTest do
25282528
test "dynamic" do
25292529
assert dynamic() |> to_quoted_string() == "dynamic()"
25302530

2531+
assert intersection(atom(), dynamic()) |> to_quoted_string() == "dynamic(atom())"
2532+
25312533
assert dynamic(union(atom(), integer())) |> union(integer()) |> to_quoted_string() ==
25322534
"dynamic(atom()) or integer()"
25332535

2534-
assert intersection(binary(), dynamic()) |> to_quoted_string() == "binary()"
2536+
assert intersection(binary(), dynamic()) |> to_quoted_string() ==
2537+
"binary()"
2538+
2539+
assert intersection(bitstring(), dynamic()) |> to_quoted_string() ==
2540+
"dynamic(bitstring())"
2541+
2542+
assert intersection(bitstring_no_binary(), dynamic()) |> to_quoted_string() ==
2543+
"bitstring() and not binary()"
25352544

25362545
assert intersection(union(binary(), pid()), dynamic()) |> to_quoted_string() ==
25372546
"dynamic(binary() or pid())"
25382547

2539-
assert intersection(atom(), dynamic()) |> to_quoted_string() == "dynamic(atom())"
2540-
25412548
assert union(atom([:foo, :bar]), dynamic()) |> to_quoted_string() ==
25422549
"dynamic() or :bar or :foo"
25432550

0 commit comments

Comments
 (0)