Commit Graph
5282 Commits
Author SHA1 Message Date
Guillaume Duboc 469acb110f Fix guard equality with short-circuit operators
Signed-off-by: José Valim <jose.valim@gmail.com>

Closes #15253.
Closes #15257.
2026-04-11 10:16:59 +02:00
José Valim 7061c37b88 Add --no-compile to mix format
Closes #15256.
2026-04-10 12:19:25 +02:00
Lukasz Samson 5d794ab17c Pass correct bitstring meta during expansion
Closes #15244
2026-04-08 18:42:12 +02:00
José Valim 0f8baa3041 Remove test with race condition (already covered in warnings_test.exs) 2026-04-04 11:17:19 +02:00
José Valim 2916f20189 Keep warnings on map/remote dispatch with/without parens
Closes #15219.
2026-03-30 10:27:58 +02:00
Jean Klingler a58a40ce48 Purge and delete modules if after_verify/2 callback fails (#15220) 2026-03-26 20:08:02 +09:00
José Valim 37bbba9d58 Document map_get behaviour, do not split term types, closes #15209 2026-03-25 08:06:50 +01:00
José Valim 2a7a37f598 Add reverse arrows for min/max, closes #15210 2026-03-25 08:00:32 +01:00
José Valim 5949bad336 Fix pretty printing of map difference 2026-03-23 22:24:00 +01:00
José Valim a9ce579829 Revert structs into export time dependencies 2026-03-23 12:52:50 +01:00
José Valim e17069e559 Protocol should not add deps on implementations, closes #15202 2026-03-19 10:17:04 +01:00
José Valim d8c921fabc Refine hd/tl in guards, closes #15198 2026-03-17 09:36:20 +01:00
José Valim 9c00059f18 Further optimize map differences and fix bug in map_update with negated keys 2026-03-16 23:27:44 +01:00
José Valim 98468bd8e3 Further optimize leaf differences 2026-03-15 12:36:35 +01:00
José Valim 7945446cb4 Allow preserving sigil metadata in container cursor to quoted
Closes #14243.
2026-03-13 20:03:34 +01:00
José Valim 5bad452d0a Show undefined function errors even on variable failure, closes #13465 2026-03-13 17:07:37 +01:00
Jonatan Kłosko 7967ff985b Add :dbg_callback option to Code eval functions (#15189) 2026-03-13 08:13:01 +01:00
Gonzalo R 4021272d42 Fix missing space typo in compiler error message (#15186) 2026-03-12 21:45:00 +01:00
José Valim df0553bd08 Do not raise false positive on not is_struct checks, closes #15183 2026-03-12 09:59:54 +01:00
Panagiotis Nezis ababaf8b08 Fix URI.merge leaking :+ marker when base path is empty string (#15179)
When merging URIs where the base has `path: ""`, the internal `:+` marker
used to track the join point between base and relative paths was being
converted to a literal "+" in the output.
2026-03-11 12:07:04 +01:00
Guillaume Duboc 51207406d0 Clarify and test gradual function application (#15173)
* Implement gradual function domains and tighten function application

Add fun_domain/1 to compute function domains for static, dynamic, and mixed function types, including explicit :badfun and {:badarity, ...} outcomes when domain extraction is not well-defined.

Refine gradual function application internals by separating static and dynamic normalization paths, documenting behavior for purely dynamic and mixed cases, and clarifying domain/compatibility handling.

Expand descr tests with gradual-application edge cases and a dedicated fun_domain test suite covering static, dynamic, mixed, and arity-error scenarios.

* Refactor function application and domain handling

* Remove fun_domain, recover coverage via fun_apply tests

fun_domain was only used in tests; its behavior is fully observable
through fun_apply (wrong-domain arg → :badarg, right-domain → :ok).
Removed it and converted the domain tests to fun_apply assertions,
adding a few previously uncovered cases along the way: pure non-fun
badfun, union-arg-type enforcement, 2-arity, mixed-arity badarity
for both static and dynamic unions, and the mixed static+dynamic
gradual domain case.

* Remove dead helpers introduced alongside fun_domain

fun_single_arity, fun_single_arity_pair, fun_non_empty_arities_of,
and fun_non_empty_arities are now unreachable. Also revert
dynamic_fun_top? to the simpler map == %{} check — the semantic
emptiness scan added in the refactor was only needed to handle
the same edge cases fun_domain was handling.

* Move mixed-arity badarity check to static side of fun_normalize_both

fun_normalize itself stays simple (no arity cross-check). The check
for other non-empty arities now lives in fun_normalize_both via
fun_other_non_empty_arities/2, and only fires for the static
component. This means:

- union(fun/1, fun/2) applied with 1 arg → {:badarity, [1, 2]}
  (static: we know one branch will always fail at runtime)

- union(dynamic_fun/1, dynamic_fun/2) applied with 1 arg →
  {:ok, dynamic(integer())} (dynamic: picks matching-arity arrows,
  wraps in dynamic() to reflect that the other branch may fail)

* Add tests for mixed-arity union behavior

Static union: badarity regardless of which arity is called with,
with the called arity listed first followed by the others.

Dynamic union: picks the matching-arity arrows and wraps in dynamic(),
gives badarity only when no arity matches at all, and falls back to
dynamic() when the arg is outside the domain but dynamically compatible.
2026-03-10 13:39:54 +01:00
Jean Klingler 78a5151865 Add support for [:raw] opts in File.read (#15172) 2026-03-10 20:07:07 +09:00
Jean Klingler 71642e381a Add Process.get_label/1 to expose :proc_lib.get_label (#15169) 2026-03-10 19:01:10 +09:00
José Valim 90b5266ca7 Do not expand negations when pretty printing tuples, see #15154 2026-03-10 08:44:12 +01:00
José Valim 382b5b06de Convert domains to also use orddict 2026-03-10 08:17:00 +01:00
Jean Klingler 2c54f9a64a More cleanup: remove compatibility code for OTP26- (#15166)
* Remove compatibility code for OTP26-

* Remove support for application/erlang+html docs v1

* Remove workaround for bug in older OTP versions

* Update OTP version checks

* Remove OTP25- skipping in tests

* More test cleanup
2026-03-10 16:12:36 +09:00
Jean Klingler 2817a70680 Remove mentions to OTP27+ versions from docs, comments and tests (#15165)
* Remove mentions of "since OTP27+"

* Remove test code for OTP26-
2026-03-10 15:39:03 +09:00
Panagiotis Nezis acd76b68ab Fix PartitionSupervisor.count_children/1 and stop/3 to support via tuples (#15161)
The `name()` type for PartitionSupervisor includes `{:via, module(), term()}`
tuples, but `count_children/1` and `stop/3` only accepted atoms, raising
`FunctionClauseError` for via tuples.
2026-03-10 07:24:37 +01:00
Panagiotis Nezis 6f9afad9ca Fix Integer.extended_gcd/2 returning negative GCD for zero base cases (#15163)
When one argument is 0 and the other is negative, `extended_gcd/2`
was returning a negative GCD, violating both the @spec (which
declares `non_neg_integer`) and consistency with `gcd/2`.
2026-03-10 07:24:29 +01:00
Panagiotis Nezis 8914dcdcbb Fix Integer.undigits/2 to validate negative out-of-range digits (#15160)
The validation was asymmetric - it rejected positive digits >= base
but silently accepted negative digits <= -base. This fix adds the
missing check for negative out-of-range digits.
2026-03-09 20:35:10 +01:00
Panagiotis Nezis 5e7671a035 Fix Float.parse/1 inconsistent error handling for non-scientific notation overflow (#15157)
`Float.parse/1` was returning `:error` for overflow in scientific notation (e.g.,
"1.0e400") but raising `ArgumentError` for equivalent overflow in non-scientific
notation (e.g., a 310-digit number). This violated the documented behavior that
states `Float.parse/1` should return `:error` when the float exceeds the maximum
size.
2026-03-09 19:30:26 +01:00
Panagiotis Nezis 52c58c72d3 Preserve directory permissions in File.cp_r/3 (#15155)
The documentation states that `cp_r/3` maintains "modes" when copying, but
directory permissions were not being preserved - only file permissions.
2026-03-09 14:40:00 +01:00
José Valim d56669789f Process fields even when structs are unknown, closes #15156 2026-03-09 14:38:54 +01:00
Panagiotis Nezis c6820a1297 Fix File.cp_r/3 infinite loop with symlink cycles (#15152)
When `dereference_symlinks: true` was set and there was a symlink cycle
(e.g., a -> b -> a), the function would infinitely recurse. This fix
tracks visited paths using a `MapSet` and returns `{:error, :eloop, path}`
when a cycle is detected.
2026-03-09 10:42:29 +01:00
José Valim 9add53318a Avoid cascading unions in map difference 2026-03-09 08:56:29 +01:00
José Valim 27aadff38d Tackle empty intersections in map fetch key 2026-03-09 08:20:45 +01:00
José Valim b98d823c54 Simplify differences (#15153)
The previous implementation was incorrectly nesting differences.
So if we had four clauses, the four clause was computing the type as:

    clause4 - (clause3 - clause2 - clause1) - (clause2 - clause1) - clause1

While it should have been:

    clause4 - clause3 - clause2 - clause1

This means that instead of `n` differences, we had an arithmetic progression
of `n * (n + 1) / 2` differences.
2026-03-08 23:02:28 +01:00
Panagiotis Nezis dd1f52917c Fix File.cp_r/3 infinite loop when copying into subdirectory of source (#15148)
When destination is a subdirectory of source, `cp_r` would enter an
infinite loop because the newly created destination directory would
be included in the file listing during recursion. This can **cause disk
exhaustion** if large files are present under source.

This adds a validation check that returns `{:error, :einval, destination}`
when copying on a subdir of the source path.

Also document typical error reasons including the new `:einval` case.
2026-03-08 11:03:10 +01:00
Jean Klingler 07e6e1a985 Warn when defining @type record(), fixes CI on OTP29 (#15150) 2026-03-08 17:10:16 +09:00
José Valim 0dbdadae4a Revert previous strategy to use multiple differences 2026-03-07 22:59:55 +01:00
Panagiotis Nezis bbe700151e Fix File.Stream Enumerable.count for files without trailing newline (#15147)
The optimized count implementation was counting newline characters
instead of actual lines, returning incorrect results for files that
don't end with a newline (which is common for source code files).

For example, a file with content "line1\nline2\nline3" (3 lines)
was returning 2 instead of 3.

The fix tracks the last byte read and adds 1 at EOF if the file
has content but doesn't end with a newline.
2026-03-07 11:54:01 +01:00
Panagiotis Nezis d61ba915b0 Raise ArgumentError on invalid binding in Code.eval_string/3 (#15146)
Previously, passing a non-list binding to `Code.eval_string/3` would crash
deep in Erlang code with a confusing `FunctionClauseError` in
`:elixir_erl_var.load_binding/6`.
2026-03-07 10:01:59 +01:00
Panagiotis Nezis 47d72d94d8 Fix Enum.slice/2 for ranges with step > 1 sliced by step > 1 (#15144)
When slicing a Range with step > 1 using a slice range that also has
step > 1, the formula for calculating the step in the slicer function
was incorrect.
2026-03-07 08:56:13 +01:00
José Valim 9a663cf3fa Convert map fields into an orddict and implement meet optimizations (#15142)
Related to #15129.
2026-03-06 21:57:55 +01:00
José Valim 6fd161d67d Optimize previous handling by using nested unions instead of nested differences
Partially addresses #15129.
2026-03-05 12:19:47 +01:00
José Valim 576f123b16 Intersection of maps with not set keys should not be empty, closes #15131 2026-03-05 10:34:03 +01:00
José Valim 77e6687eef Handle Kernel.in/2 in type system instead of using rewrite rules, closes #15130 2026-03-05 08:48:03 +01:00
José Valim 0ea809e720 Check redundant clauses for definitions (#15124) 2026-03-02 17:19:51 +01:00
Jean Klingler cd38841a18 Raise clearer error when reserved word used at the top level of defmodule (#15123) 2026-03-02 18:18:35 +09:00
Jean Klingler 132197a254 Remove redundant clause triggering warning in tests (#15122) 2026-03-02 17:17:07 +09:00