Commit Graph
204 Commits
Author SHA1 Message Date
José Valim cb2e03688e Perform return type inference and application across local calls (#13984) 2024-11-11 23:06:31 +01:00
José Valim 57de6ea33a Type behaviour_info, module_info, and __info__ 2024-11-08 12:33:08 +01:00
José Valim c35d002dc2 Fix column information in tests 2023-10-24 00:36:24 +02:00
José Valim 09946ee776 Include column information on definition metadata
Closes #13029.
2023-10-23 20:12:20 +02:00
Jean Klingler a94700f861 Fix unused function warning with overridables (#12865) 2023-08-16 16:18:07 +09:00
Jean Klingler ba4c160080 Warn on unused defp/defmacrop using unquote/1 (#12832)
* Remove unused macro

* Remove unused default arg in test

* Warn on unused defp/defmacrop using unquote/1

* Add tests for metaprogrammed clauses without warnings
2023-08-05 19:07:50 +09:00
José Valim ee4e0be947 Reduce AST metadata compiled in definitions 2023-02-09 12:20:01 +01:00
José Valim b24869687b Introduce mechanism to collect several errors in a module (#12275) 2022-11-28 15:40:30 +01: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 6bb2eb317b Treat requires from local macros as compile-time deps 2022-07-11 13:17:01 +02:00
José Valim 2a7d58c3f7 Register functions used in local macros as exports
Ideally we want to list them as requires but we don't have
the infrastructure to do so. So meanwhile, we list them
as exports, which is the same level used by require.
2022-07-11 09:09:54 +02:00
José Valim 25002872b8 Keep file env consistently as an absolute path, closes #11964 2022-07-05 23:04:03 +02:00
sabiwara 04eda2e8f8 Fix bug in fn defaults (#11963)
Closes #11961.
2022-07-05 16:02:01 +02:00
sabiwara 1c3ef5ab99 Fix variable declaration in default argument block (#11758) 2022-04-16 14:59:20 +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 6e13236404 Do not ignore unimplemented function headers from used modules 2021-04-07 18:52:38 +02:00
José Valim eaa48e4f5b Allow @on_load to be private, closes #10438 2020-10-17 20:08:06 +02:00
Eksperimental b39b7b5e64 Mention file:line in Already defined as ... error message (#10219) 2020-07-22 14:59:37 +02:00
José Valim 2dc1a79252 Revert "Use an empty keyword list instead of nil for empty definitions"
Closes #9910

This reverts commit db4cb93ae3.
2020-03-24 20:21:01 +01:00
José Valim dbf8a7a9fe Use version metadata in Erlang pass 2019-11-16 02:45:55 +01:00
Eric Meadows-Jönsson a3fc4b3f9e Add variable version to expanded meta (#9520) 2019-11-13 12:57:21 +01:00
Glauber Campinho a829084bb8 Raise error on functions/guards without implementation (#9461)
Fixes #9392.

When a local bodiless function is called the generated Erlang code is invalid, this commit checks for bodiless locals during the compilation and raises an error on that avoiding the invalid code.
2019-10-31 07:00:43 -05:00
José Valim 329d9b8475 Warn when function head comes immediately after the implementation 2019-08-15 19:23:38 +02:00
José Valim db4cb93ae3 Use an empty keyword list instead of nil for empty definitions 2019-08-14 14:51:49 +02:00
José Valim 9790329a08 Add compiler tracing (#9247)
This feature allows IDEs and other tools wanting to
perform source code analysis to do so reliably without
a need to reimplement Elixir's compiler expansion and
without relying on Elixir's private APIs.

This commit also adds :parser_options to compiler
options, which allows developers to combine both options
to retrieve more accurate information, such as columns.
2019-08-02 13:35:12 +02:00
José Valim 5358110ab0 Consider @file attribute on undefined locals, closes #9005 2019-05-02 20:20:21 +02:00
José Valim 8c285ac95b Only linify if keep was given 2019-05-02 18:57:44 +02:00
José Valim e80b55b21c Unify error handling and compiler deadlock checking (#9009) 2019-05-02 16:27:13 +02:00
José Valim a34478f693 Do not change super signature, pass info as metadata 2019-03-01 08:58:53 -08:00
José Valim 78673011de Make __info__ docs a callback, closes #8376 2018-11-12 14:16:40 +01:00
José Valim 8bc458e044 Ensure eval_quoted properly resets last definition, closes #8261 2018-10-09 20:49:38 +02:00
Glauber Campinho 5b48933f47 Let the undefined function error be performed in Elixir-land (#8231)
Refers to #5800
2018-10-01 12:22:38 +02:00
Glauber Campinho 690b2e572a Use head definition meta to warn about unused args (#8198)
Fixes #8184
2018-09-16 10:44:26 +02:00
José Valim fa46949b5b Rename definition header to function head 2018-07-26 21:27:48 +02:00
José Valim 59e3000a25 Tiny perf improvements to the compiler 2018-07-23 11:23:50 +02:00
José Valim 4580764ffa Do not include overridables in definitions, closes #7823 2018-07-03 12:39:58 +02:00
José Valim 893f5b3ab6 Avoid no match clauses from generated definitions 2018-05-11 08:25:46 +02:00
Glauber Campinho 52293c198a Consider if definition should be checked for @impl
Fixes #7617

Signed-off-by: José Valim <jose.valim@plataformatec.com.br>
2018-05-10 23:05:40 +02:00
Zacck Osiemo 3786fe9af8 Provide better warnings when grouping multi clause functions (#7630) 2018-05-03 21:48:06 +02:00
José Valim a77a6259f4 Avoid false positive warnings 2018-04-30 21:04:35 +08:00
José Valim f134113c54 Improve coverage and error messages when mixing clauses with defaults
In case a bodiless clause with defaults was defined twice,
Elixir would raise an error. This commit fixes this and also
provide two distinct messages: an error in any situation a
default is declared more than once. And a warning in case
defaults are defined once but not as the first clause.
2018-04-29 17:09:32 +08:00
José Valim 74f3d36d4f Move accumulate attributes to a separate table (#7472)
We also speed up reading and writing of attributes via the @ macro.
2018-03-21 17:13:43 +01:00
José Valim 882e7b8af4 Share Bag and Set tables across a module functionality
Previously we kept a Set table for attributes and a Bag table
for function definitions and clauses. This led to suboptimal
usage of ets tables.

With this commit, we start using both Bag and Set tables
to store function/macro definition information. In the next
commits we will continue generalizing the tables, storing
specs, docs and accumulated attributes in the Bag and keep
the remaining functionality in Set.
2018-03-20 10:30:37 +01:00
José Valim c408dac2d9 Consistently raise for missing do option in definitions
Closes #7333.
2018-02-09 17:05:59 +01:00
José Valim 2604437cd2 Restart contextual vars on function definitions 2018-02-03 23:21:30 -02:00
Michał Muskała 5d4e1c6bb0 Use contextual vars for __CALLER__ (#7309) 2018-02-03 23:10:40 -02:00
José Valim fd4dc4474a Process variable versioning on Elixir pass 2018-01-20 19:42:08 +01:00
Glauber Campinho 1ed51a6f65 Remove multiple clauses warning for default values on bodiless clause (#7092) 2017-12-11 21:38:49 +01:00
José Valim 192aee5164 Use a single table instead of digraph for tracking locals
This reduces the number of spawned ETS tables from 3 to 1
per local tracker and also removes the need for a separate
process.

Closes #7091.
2017-12-06 19:49:54 +01:00
Glauber Campinho fe47af5075 Warn duplicate definitions in macros (#7037)
Closes #6637
2017-11-15 20:52:28 +01:00