Commit Graph
307 Commits
Author SHA1 Message Date
José Valim 3120d4539b Type checked struct operations must not deadlock the compiler 2026-05-04 01:24:42 +02:00
José Valim 603602e67b Implement reverse arrows for case (#15260) 2026-04-13 15:21:08 +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 b05fec0c87 Use evaluation when compiling modules (#15087) 2026-02-19 18:11:28 +01:00
José Valim f1bbb2cd32 Infer types from guards and do post-inference on stdlib (#15032)
We now infer types from guards although we don't
yet infer conditional types (such as on `or`).
2026-01-02 19:48:45 +01:00
José Valim dc6647c0e9 Pass signatures on the side instead of module map 2025-10-23 00:18:14 +02:00
José Valim 781d500246 Checkpoint before verification to avoid ignore modules warnings 2025-10-05 15:36:13 +02:00
José Valim 2e55f40713 Do not persist temporary compilation warnings, closes #14768 2025-09-14 10:26:55 +02:00
José Valim 64a387da82 Load modules lazily and only if needed (#14453) 2025-04-28 12:45:25 +02:00
José Valim c20222ba0b Trace on load functions, see #14427 2025-04-26 08:42:56 +02:00
Jonatan Männchen e1d171e5c7 Add inline License / Copyright to Erlang files (#14255) 2025-02-05 13:50:00 +01:00
José Valim 30764fe67d Add type checking of protocol implementations (#14115) 2024-12-26 09:00:45 +01:00
José Valim 27a825aaf3 Annotate nifs to accumulate 2024-12-20 10:03:44 +01:00
José Valim bb028b951f Always consider Elixir modules on inference (#14000) 2024-11-19 13:40:16 +01:00
José Valim bfebc1e30b Fix Dialyzer failures 2024-11-13 00:37:37 +01:00
José Valim cb2e03688e Perform return type inference and application across local calls (#13984) 2024-11-11 23:06:31 +01:00
José Valim 485ca72ae2 Infer types and use them across remote calls (#13981)
This also unifies handling of deterministic builds with Erlang/OTP
as well as warnings_as_errors.
2024-11-09 18:00:27 +01:00
José Valim 9d1933b679 Use attributes field to compute behaviours 2024-11-08 12:33:08 +01:00
Jonatan Kłosko 1c19c60abb Add source and behaviour information to docs chunk metadata (#13914) 2024-10-30 09:18:00 +01:00
José Valim c7fa5f95fc Add Macro.struct_info! 2024-10-26 09:21:04 +02:00
José Valim 8c5c421b58 Avoid compiling some values twice when building .beam 2024-06-14 09:06:56 +02:00
José Valim 1b6c31a0eb Avoid the number of duplicate traces on imports 2024-05-25 11:10:22 +02:00
José Valim d120affb11 Emit defmodule tracing event 2024-02-26 18:28:40 +01:00
José Valim aabe46536e Disable compiler optimizations only in module body 2023-12-10 03:23:45 +11:00
José Valim 08f315016f Add @nifs attributes 2023-10-25 23:53:24 +02:00
José Valim 44d3faad45 No longer track module as context inside after_compile 2023-10-11 15:53:41 +02:00
José Valim 58bb5194d3 Propagate diagnostics from inner compiler process 2023-07-06 09:41:57 +02:00
José Valim d4d7c8bcfd Raise when macros are given to dialyzer, closes #12597 2023-05-25 11:38:23 +02:00
José Valim a0f0f75ee8 Add Code.with_diagnostics/2, closes #12276 2023-05-16 11:52:59 +02:00
José Valim b24869687b Introduce mechanism to collect several errors in a module (#12275) 2022-11-28 15:40:30 +01:00
José Valim 749349205d Do not include module variables in prune_binding 2022-11-08 11:34:55 +01:00
José Valim 439a138089 Revert pruning of defmodule 2022-11-08 00:40:20 +01:00
José Valim 1fc747c75e Add prune binding to module tracing event 2022-11-08 00:40:20 +01:00
Marc-André Lafortune b5d40c6f99 Behaviour as runtime dependency (#12103) 2022-08-30 08:34:08 +02:00
José Valim c94924a6c2 List compile-time deps for after_verify 2022-08-29 23:37:21 +02:00
José Valim 03514d70eb Add @after_verify callback
@after_verify hooks are invoked right after the current module is verified for
undefined functions, deprecations, etc. A module is always verified after
it is compiled. In Mix projects, a module is also verified when any of its
runtime dependencies change. Therefore this is useful to perform verification
of the current module while avoiding compile-time dependencies.

Here are some sample use cases:

  * Ecto can use this validate associations consistently and effectively
  * Phoenix can use this to verify routes
  * Surface can use this to verify component attributes
2022-07-20 16:34:15 +02:00
José Valim 7913d5d02e Lazily expand module attributes to avoid compile-time deps
Before this patch, this code would add a compile-time
dependency to Bar and Baz:

    defmodule Foo do
      @mods [Bar, Baz]
      def example(arg) when arg in @mods, do: arg
    end

That's because Bar and Baz were read in the module body,
even though ultimately they are only expanded and used
inside a function.

This patch postpones the expansion of aliases until they
are used. So if `@mods` is only used inside functions,
no compile-time deps are added.

Closes #11714.
2022-07-14 16:36:43 +02:00
José Valim ed82538f9a Simplify passing of values to the checker 2022-07-12 12:55:48 +02:00
José Valim 5f0454d27d Start checker processes lazily 2022-07-12 12:13:04 +02:00
José Valim 4a5efd5ec3 Improve Inspect for structs (#11897)
* Inspect in the defstruct order
* Mark optional fields that match the default value when deriving
* Add __info__(:struct) with metadata
2022-06-03 23:32:17 +02:00
José Valim 7c8d6ffb46 Warn on underived derives, closes #11799 2022-05-06 12:44:06 +02:00
Daven 7ef962fe30 Warn if any of True, False, and Nil aliases are used (#11731) 2022-03-28 07:28:34 +02:00
José Valim 080528a308 Simplify contract between checker and compiler 2021-12-18 22:05:49 +01:00
José Valim 03d3119b53 Do not allow slashes in module names
Closes #11216.
2021-08-29 10:13:22 +02:00
José Valim 92a2eb6328 Add mix xref trace that shows all deps for a given file (#11184) 2021-08-17 18:04:15 +02:00
José Valim 5eb2efe543 Break Macro.Env apart (#11164)
Previously, the internal Elixir expansion pass worked directly on
Macro.Env. However, this poised an issue, if we want to track
more information in the pass, we ended up exposing it on
Macro.Env, making it larger, and potentially slowing down
operations such as __ENV__ serialization.

This commit refactors the expansion pass to work with two
structures, the Macro.Env struct and a #elixir_ex{} record.
2021-08-03 13:35:15 +02:00
José Valim d65349b47c Add {:on_module, bytecode, :none} to compilation tracers
See #11145.
2021-07-27 13:17:31 +02:00
José Valim a355450af8 Ensure waiting is tracked across typespecs
The Elixir compiler spawns a separate process per file.
When a file has to wait on another module, Elixir tracks
in the compiler that the file is waiting.

However, every time a module is defined, the Elixir compiler
spawns a separate process to compile to .beam, and this
process may expand structs in the typespec. Since this
new process is no longer the original file process, Elixir
was not able to track its waiting time.

This PR address this issue by passing the original file_pid
to the .beam compiler process. Note though that, if we
change typespecs to be compiled in the original file process,
this change is no longer required, but at the moment there are
no plans to make such change.

Closes #11036.
2021-06-05 19:21:12 +02:00
José Valim 3c45984d2c Assume Elixir is not started when accessing configs 2021-05-21 12:02:15 +02:00
José Valim f2689a4b48 Clean up shared parallel checker table 2021-05-09 09:08:39 +02:00