Commit Graph
1711 Commits
Author SHA1 Message Date
José Valim d33bac539c Allow :deprecated to be given as doc metadata 2018-07-11 11:01:57 +02:00
László Bácsi 0267ae2c7e Support adding arbitrary docs metadata with @doc keyword() (#7852) 2018-07-11 10:19:38 +02:00
José Valim bed2547895 Properly inflect names for structs 2018-07-10 14:02:41 +02:00
Laszlo Bacsi cf68b9f652 Move compilation of docs metadata to Elixir side 2018-07-10 13:42:20 +02:00
José Valim e16775d5a4 Lift signature_to_binary from ExDoc 2018-07-10 11:29:39 +02:00
José Valim beb596d37c Warn on unnecessary quotes (#7838) 2018-07-10 10:27:02 +02:00
José Valim 6cf3d8c20a Return error tuple for long quoted atoms 2018-07-09 10:49:38 +02:00
Adrian Cruz dd880e209c Return an error tuple for interpolation in function call (#7836) 2018-07-09 10:24:26 +02:00
José Valim 83e6358b14 Fixes to binary generators with collectable into in comprehensions
This fixes two bugs/limitations:

  1. When using dynamic size in the binary pattern
  2. When using literals in the binary pattern

Closes #7829.
2018-07-05 13:09:18 +02:00
José Valim 32450a0fd9 Remove Code.get_docs/2 and streamline the new chunk generation 2018-07-05 10:31:23 +02:00
László Bácsi 2ecb5d00bd Adopt EEP 48 and add Code.fetch_docs/1 (#7826)
At this point the legacy chunk and the original `Code.get_docs/2`
implementation is still in place, but the tests have been adjusted to
exercise `Code.fetch_docs/1` instead.
2018-07-03 18:43:41 +02:00
José Valim e7bd7c98e0 Do not include overridables in definitions, closes #7823 2018-07-03 12:39:58 +02:00
José Valim 2ece95c1db Handle other unescaped tokens in tokenizer 2018-07-03 12:14:16 +02:00
Adrian Cruz 9707843134 Return error on bad hex escaping (#7809)
As discussed in #7270, it would help if we return error tuples
instead of exceptions. This PR does it for string unescaping.
2018-07-03 12:03:43 +02:00
José Valim 5fbc8676c2 Improve error messages for bad map key patterns 2018-06-25 16:56:57 +02:00
lukevmorris 2f268088af Warn if nested comparisons are found (#7773) 2018-06-21 18:59:52 +02:00
Derek Kraan 95acb1f751 Include caller information on struct expansion errors
Closes #7752
2018-06-21 18:48:55 +02:00
José Valim 22245a44fe Only show mismatch hints for fn+do/end 2018-06-21 14:08:30 +02:00
José Valim faa0e84fa6 Revert "Support for map.field in guards"
Let's explore alternatives before settling on this one.
2018-06-21 10:40:19 +02:00
José Valim c024b0eeb2 Add handle_continue/2 and deprecate super in GenServer callbacks 2018-06-20 23:53:55 +02:00
José Valim 5f31e5b146 Allow map.field in guards for Erlang/OTP 21+ 2018-06-20 23:18:44 +02:00
José Valim d27062c8ec Add Code.purge_compiler_modules/0
Closes #7047
2018-06-20 20:51:05 +02:00
Michał Muskała 8a64261b22 Replace use of rebar in build scripts 2018-06-15 14:11:19 +02:00
Michał Muskała 071c41b2ce Refactor __info__ so it generates smaller assembly (#7753)
The phash value changes because clauses for the `__info__` function
are now ordered differently
2018-06-14 15:58:09 +02:00
José Valim 396e0bff9f Only compute eol if necessary 2018-06-10 17:53:40 +02:00
Sihui Huang 47f1107a7a When fn is followed by a newline, use multi-clause formatting style (#7737) 2018-06-10 17:45:02 +02:00
José Valim 5edb1d2739 Add hints on mismatched do/end and others pairs
When you are working on large files and you add new code,
you may forget to add a `do` or an `end`. In those cases,
the error message usually points to the first `do` or the
last `end` in the file, which are usually far away from
the source of the error.

This pull request adds a simple heuristic based on the
indentation of the tokens, to try to provide hints of
where the source may be. Those hints are not deterministic
but they may be able to point users to the source of the
problem.

For example, in this case:

    defmodule MyApp do
      def one do
      # end

      def two do
      end
    end

we know that we now that `def two do` is happening on the
same indentation as `def one do`, which may mean that
`def one do` was not closed properly. We store this as a
hint in case the terminators do not match later.

Similarly, in the case below:

    defmodule MyApp do
      def one
      end

      def two do
      end
    end

The `end` on line 3 will end-up closing the defmodule `do`,
on line 1. Because their indentation do not match, it may
be that there is a missing `do`, where the `end` was supposed
to align.

Some basic testing show those heuristics work on the majority
of the cases, but we will only be sure when we have enough
feedback from the community.
2018-06-10 13:55:49 +02:00
René Föhring 1ade3c0dd9 Fix column in :elixir_tokenizer for double quotes in keyword identifiers (#7722)
This fixes cases where `:elixir_tokenizer` does not account for double
quotes in keyword identifiers when determining the column for the next
token.
2018-06-04 16:06:42 +02:00
Glauber Campinho 54a29ddde0 Remove unnecessary catch from the parser (#7674)
The throws with this pattern are (caught by yecc)[https://github.com/erlang/otp/blob/master/lib/parsetools/include/yeccpre.hrl#L67]
and returned as an error. Also renamed throw to error to avoid confusions.
2018-05-12 10:27:05 +02:00
José Valim 7976771b30 Avoid no match clauses from generated definitions 2018-05-11 08:25:46 +02:00
Glauber Campinho 4bc3527134 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
Andrea Leopardi 60bc0aeae9 Slightly refactor some code in elixir_erl_try 2018-05-10 18:43:57 +02:00
Aleksei Magusev 2a7abb7f72 Implement illegal_bin_pattern check in Elixir pass (#7444) 2018-05-07 17:25:08 +02:00
José Valim 75541cf472 Condititionally compile and lazily compute __STACKTRACE__ (#7648)
Erlang/OTP 20 warns if the stacktrace is read outside of a
catch/rescue. This commit mirrors this behaviour by consistently
warning on `System.stacktrace/0` being used outside of a
catch/rescue.

Erlang/OTP 21 warns whenever System.stacktrace/:erlang.get_stacktrace
are used. Therefore we need to promote the usage of `__STACKTRACE__`
and make sure to conditionally compile it according to the OTP version.
This requires changes to the Exception normalization mechanism
so we compute `__STACKTRACE__` only when strictly required.

In future Elixir releases, `System.stacktrace/0` will warn when
used even inside catch/rescue.
2018-05-07 15:33:36 +02:00
José Valim f51865bd14 Avoid capture operator warnings 2018-05-04 19:50:49 +02:00
Zacck Osiemo 608d7f814f Provide better warnings when grouping multi clause functions (#7630) 2018-05-03 21:48:06 +02:00
José Valim 11a0b39ad4 Move stdlib deprecations to @deprecated attribute (#7637) 2018-05-03 20:31:34 +02:00
José Valim e28931fdaa Pass tracker destination forward to dynamicly defined modules 2018-05-02 12:18:50 +02:00
José Valim 371423a93f Avoid false positive warnings 2018-04-30 21:04:35 +08:00
José Valim ff31f4d663 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
Eksperimental 5e987a702b Standardize use of Erlang, OTP and Erlang/OTP names (#7618)
This touches only messages directed to the end user,
so comments are ignored.

This is important, specially for newcomers, who may be confused
by the interchangeable use of Erlang and OTP.

The expressions used consistenly across the documentation are:
- Erlang/OTP version
- Erlang/OTP 20+
- Erlang/OTP release,
- Erlang/OTP documentation
- Erlang process
- Erlang project
- Erlang's error logger
- Erlang log message
- OTP application
- OTP behaviour
2018-04-28 07:34:26 -03:00
Eksperimental d17ac42a5f Remove unused convenience vars in elixir_rewrite (#7612) 2018-04-28 12:06:00 +08:00
Andrea Leopardi 1aba6f72c6 Warn when a variable/atom that ends in / or ? is followed by = with no space (#7608) 2018-04-27 16:49:11 -03:00
Glauber Campinho 4398927789 Erase elixir_parser_columns from the process dictionary after use (#7601) 2018-04-27 00:39:18 +08:00
eksperimental 2921f0165b Mention in the docs every function inlined by the compiler
elixir_rewrite.erl has been audited, function by function:
- All missing "Inlined by the compiler." lines have been added.
- Standardize sentence avoid mentioning the function its inline to (System module).
- "Inline by the compiler." goes always before ##Options or ##Examples
2018-04-26 18:58:07 +08:00
eksperimental 36d4cbf384 Sort alphabetically elixir_rewrite.erl 2018-04-26 18:58:07 +08:00
Glauber Campinho 74e6661569 Add meta generated to for/1 clauses with bitstrings (#7560)
Closes #7508.
2018-04-20 00:13:24 +02:00
Glauber Campinho 2865ded07e Check if the left argument of the lists concatenation is a proper list (#7556)
Fix illegal pattern error in Erlang:
```
iex(1)> [1 | 2] ++ [3] = [1, 2, 3]
** (ErlangError) Erlang error: {:illegal_pattern, {:op, 1, :++, {:cons, 0, {:integer, 0, 1}, {:integer, 0, 2}}, {:cons, 0, {:integer, 0, 3}, {nil, 0}}}}
iex(1)> [1] ++ 2 ++ [3] = [1,2]
** (ErlangError) Erlang error: {:illegal_pattern, {:op, 1, :++, {:cons, 0, {:integer, 0, 1}, {nil, 0}}, {:op, 1, :++, {:integer, 0, 2}, {:cons, 0, {:integer, 0, 3}, {nil, 0}}}}}
```
2018-04-16 22:13:49 +02:00
José Valim cfaf9dbbcd Improve warning about escaped codepoints in ? 2018-04-11 09:25:42 +02:00
José Valim fc857d6ff1 Raise on invalid pin in maps, closes #7543 2018-04-10 20:49:53 +02:00