Commit Graph
5360 Commits
Author SHA1 Message Date
José Valim 76fbc0ccbc Do not discard variables in cond
When traversing the case for the reverse arrow, if there are
no changes, the case-expr are not re-executed, which meant
variables would not be redefined.

Closes #15402.
Closes #15403.
2026-05-19 13:15:58 +02:00
Jean Klingler 315279701a Fix dialyzer opaqueness violation with MapSet (#15399) 2026-05-17 19:45:56 +09:00
José Valim 57b1685cac Collect diagnostics across clauses in rescue, closes #15307 2026-05-16 18:12:45 +02:00
José Valim 87582af546 Preserve evaluation order when rewriting (#15389)
This was done by moving the rewriting which change evaluation order to the Erlang pass,
otherwise would be hard to rewrite back in the type checker reports.

Closes #15310.
2026-05-14 21:16:55 +02:00
Guillaume Duboc 63708d313c Type system support for put_elem/3 (#15388) 2026-05-14 20:45:33 +02:00
Guillaume Duboc e7a5a667bf Make tuple_insert_at preserve static part of a type (#15387) 2026-05-14 20:44:54 +02:00
Guillaume Duboc 367e38cbe6 Fix if_set dropping static part of type (#15379) 2026-05-14 20:44:22 +02:00
Łukasz Samson 909b099d44 Fix dynamic-value error wrapping in tuple_insert_at/3 (#15382)
Propagate `badtuple` and `badindex` error from `tuple_insert_at_checked` to the caller instead of wrapping it in `dynamic`
2026-05-14 16:23:46 +02:00
José Valim 5509b95437 Group clauses by return, closes #15371 2026-05-14 15:38:47 +02:00
Łukasz Samson 0792999f63 Fix invalid error message on tuple operations with negative index (#15380) 2026-05-14 15:38:28 +02:00
José Valim 41332ac3d6 Silence warnings on charlist formatting 2026-05-14 14:03:32 +02:00
José Valim 6b114ee7c1 Avoid false positives when comparing structs with dynamic
Closes #15370
2026-05-14 13:53:25 +02:00
Guillaume Duboc 71148aa953 Tuple operations performance boost + fix logic bug (#15376) 2026-05-14 12:44:18 +02:00
José Valim b35e210321 Properly format or/and in type errors
See #15369.
2026-05-14 12:43:28 +02:00
José Valim aad63173b8 Clarify semantics of defguard, closes #15284 2026-05-13 18:53:13 +02:00
Guillaume Duboc 472a49d84a Preserve static parts in dynamic container descriptors (#15363) 2026-05-13 11:45:23 +02:00
José Valim 8bdd041122 Add missing exclamation mark 2026-05-13 10:35:57 +02:00
José Valim 0eabf48524 Refine types from case on inference 2026-05-12 20:15:16 +02:00
Guillaume Duboc b0db1a26e1 Performance boost on map operations + bugfix (#15362)
Add the two important optimization paths for negative-map projection: value-side projection for map fetch/get and shape-side projection for map put/update.

Keep regression coverage for projected negative maps.
2026-05-12 18:50:17 +02:00
José Valim 35eeab3511 Fix regression on default inference, closes #15359 2026-05-12 14:59:53 +02:00
José Valim aae39c87dc Fix warnings 2026-05-12 14:49:36 +02:00
José Valim 8a2c815c85 Propagate hd/tl checks across clauses, closes #15358 2026-05-12 14:06:08 +02:00
José Valim 41353c6cf8 Infer precise types for default arguments 2026-05-12 10:40:25 +02:00
José Valim 3e3ce13c1d Deal with raising clauses in cond 2026-05-11 12:45:42 +02:00
José Valim 4816d3773a Perform occurrence typing in cond 2026-05-11 11:51:03 +02:00
José Valim 5b8b8e3589 Reintroduce escaped trailing newlines in heredocs in Macro.to_string/2 (#15355)
Closes #15354.
2026-05-11 10:18:49 +02:00
Łukasz Samson 8a35ffa811 Reject negative Duration in to_timeout (#15352)
Previously a negative timeout value violating the spec was returned
2026-05-08 22:28:48 +02:00
Łukasz Samson a5435a6ead Reject invalid config shapes in Config.validate!/2 (#15349)
Previous code used `Enum.all?` and silently skipped invalid pairs
2026-05-08 11:01:32 +02:00
Łukasz Samson c3f7e3473e Raise in Stream.cycle when enumerable reduce call yields no elements (#15344) 2026-05-06 12:22:53 +02:00
Łukasz Samson 68c413f76c Improve ambiguous import error message (#15335) 2026-05-06 12:22:34 +02:00
Guillaume Duboc c376c0feb6 Hash-cons BDD descriptors (#15332) 2026-05-04 11:55:53 +02:00
Guillaume Duboc 5858e7c470 Fix wrong intersection with union of dynamic() (#15340) 2026-05-04 10:20:51 +02:00
Guillaume Duboc 2fd350672b Fix truthiness implementation (#15339) 2026-05-04 10:18:58 +02:00
José Valim 002e382794 Raise when loading struct info 2026-05-04 10:09:24 +02:00
José Valim 46841a22e4 Test we consider external variables as not precise, fix CI 2026-05-04 09:52:24 +02:00
José Valim bdf8e4481d Refine reverse arrows when only one clause remains 2026-05-04 01:24:42 +02:00
Guillaume Duboc 81975a2de1 Fix descr edge cases (#15338) 2026-05-02 23:15:51 +02:00
Łukasz Samson 39d646f459 Include sigils option in invalid import error message (#15334) 2026-05-01 23:04:20 +02:00
Peter Ullrich 11f7d8f84a Refactor Float.round/2 algorithm for better performance (#15329)
The previous implementation noted the trade-off:

```elixir
# This implementation is slow since it relies on big integers.
# Faster implementations are available on more recent papers
# and could be implemented in the future.
```

It computed `m * power_of_5(count)` where `count` could grow to ~104, producing 250-bit bignums for a single division. The cost grew with both float magnitude and target precision.

### Benchmark results

11 different float workloads, measured with Benchee on Apple M2. Reported times are the median μs of one iteration over all 11 workloads.

precision | current | cox (this PR) | native_double | cox vs current | native_double vs current | native_double vs cox |
|---|---|---|---|---|---|---|
| 0 | 0.25 μs | 0.25 μs | 0.25 μs | 1.1× | 1.1× | ~tied |
| 1 | 2.42 μs | 0.33 μs | 0.33 μs | **7.1×** | 7.0× | ~tied |
| 2 | 2.67 μs | 0.63 μs | 0.33 μs | **3.8×** | 7.7× | 2.0× |
| 3 | 4.29 μs | 0.63 μs | 0.33 μs | **5.8×** | 11.9× | 2.1× |
| 5 | 5.50 μs | 0.67 μs | 0.33 μs | **6.8×** | 15.6× | 2.3× |
| 8 | 7.21 μs | 0.96 μs | 0.38 μs | **7.5×** | 19.5× | 2.6× |
| 12 | 7.75 μs | 0.96 μs | 0.38 μs | **8.2×** | 20.3× | 2.5× |
| 15 | 8.58 μs | 1.58 μs | 0.38 μs | **5.3×** | 22.8× | 4.3× |

Median μs per iteration over the 11-float mixed workload (per-call median ≈ value / 11).

- **`current`** is the bignum-based implementation we're replacing
- **`cox`** is this PR
- **`native_double`** is included as a "what does this look like in pure native float arithmetic" reference (`:erlang.round(f * pow) / pow`) - it's 2-4× faster than Cox but incorrect on tie inputs because `5.5675 * 1000` rounds to `5567.5` in IEEE due to double-rounding (multiplication round + integer round), then bumps to `5568`. It's why we can't simply use the obvious approach. Cox preserves exact semantics by working on the float's true binary representation.

#### Floats benchmarked

```
floats = [
  {"small_pi",       3.141592653589793},   # typical small value
  {"common_money",   5.5675},               # tie-boundary case
  {"large_e10",      1.2345e10},            # large magnitude
  {"tiny_e_neg8",    1.2345e-8},            # very small magnitude
  {"near_zero",      0.00001},              # close to zero
  {"negative",       -123.456789},          # negative sign
  {"integer_valued", 12.0},                 # exactly representable integer
  {"tie_half",       12.5},                 # half-tie
  {"tie_5675",       5.5675},               # documented tie example
  {"large_e30",      1.234e30},             # very large
  {"max_finite_ish", 1.7e308}               # near max double
]
```
2026-05-01 12:59:07 +02:00
Łukasz Samson f4e1b34617 Fix incorrect guard type refinement with length/map_size and != operator (#15327)
Previously `empty_list()` and `empty_map` were returned for `length(x) != n` and `map_size(x) != n` when n > 0. Now the types are widened to `list()` and `open_map()`
2026-04-30 18:30:07 +02:00
José Valim 55a3899e75 Add more tests around precision 2026-04-29 22:10:46 +02:00
Łukasz Samson ada2817d72 Fix invalid type inference on size compare in guards (#15324) 2026-04-29 22:06:23 +02:00
Guillaume Duboc 89e0106afc Fix map union optimization for open maps (#15322) 2026-04-29 08:48:16 +02:00
Łukasz Samson e39a1ca796 Consistently return path as binary in relative_to_cwd (#15316)
Previously if path parameter was passed in as chardata it was returned as is on `:file.get_cwd` failure
All `relative_to` and `join` code paths normalize to binary
2026-04-28 22:51:09 +02:00
Łukasz Samson 007efde2d5 Fix reentrancy of Code.eval_* (#15306)
Keep env and dbg callbacks on stacks in process dict

Closes #15303
2026-04-28 19:38:28 +02:00
Guillaume Duboc eb8bbc9c29 Fix map difference union optimization (#15319) 2026-04-28 19:12:34 +02:00
José Valim c5332235ab Perform all side-effect in order in in/2 2026-04-27 12:25:49 +02:00
José Valim e5d8b00e5b Remove maps:put/3 inlining, as it is done by the Erlang compiler, closes #15313 2026-04-27 12:03:24 +02:00
José Valim 2ba06cc40b Make preserving dir permissions opt-in, closes #15308 (#15312) 2026-04-26 19:08:23 +02:00
José Valim 68aae43703 Revert "Add each_directory to File.rm_rf, closes #15308 (#15311)"
This reverts commit d02e61d75e.

It did not address the original root problem.
2026-04-26 18:02:46 +02:00