Commit Graph
3260 Commits
Author SHA1 Message Date
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
László Bácsi caa90b563a Migrate to Code.fetch_docs/1 (#7828) 2018-07-05 00:45:04 +02:00
José Valim cd0cb7cca4 Do not leak inner key representation in signature 2018-07-03 23:30:41 +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 b0cc54468e Unify handling of keywords with and without parens 2018-07-03 17:57:13 +02:00
José Valim 4416854a9d Improve error messages for boolean operators with =, closes #7730 2018-07-03 14:37:41 +02:00
José Valim 005f432671 Warn for redefined docs across clauses
Closes #7817
2018-07-03 13:06:31 +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
Alex Castaño 374480e2e1 Annotates arithmetic error for better debug experience 2018-06-27 12:32:04 +02:00
Fernando Tapia Rico e3b2b09cce Make test suite for assert_no_guard more robust (#7801)
If I got it right, one of the reasons for that change was to get the message:

> invalid expression in guard, **!** is not allowed in guards. To learn more about guards, visit: https://hexdocs.pm/elixir/guards.html  

instead of:

> invalid expression in guard, **case** is not allowed in guards. To learn more about guards, visit: https://hexdocs.pm/elixir/guards.html

This change should make the test suite more robust for future changes or refactors :)

In addition, I've split a couple of strings that were exceeding the maximum line length (98). By the way, should the formatter warn when it cannot keep the code under the desired line length? maybe with a `--strict` flag?
2018-06-27 12:22:39 +02:00
Devon Estes e07ccb1df5 Add blame callback for KeyError (#7803)
This starts with an initial implementation of the `blame/2` callback
for `KeyError` to add some helpful `did_you_mean` feedback for
potentially typo'd keys. Right now it's only implemented for maps and
keyword lists, and only for atom keys.
2018-06-27 11:27:06 +02:00
Sihui Huang 2a610bd005 Add assert no guard on !, && and || (#7797) 2018-06-26 09:39:43 +02:00
José Valim 5fbc8676c2 Improve error messages for bad map key patterns 2018-06-25 16:56:57 +02:00
Michał Muskała d225f4a373 Restore and/or optimisation (#7764)
The optimize_boolean option is very sensitive to the order of
clauses and the optimisation was not happening for and/2 and or/2.

Add regression tests to ensure that won't happen again.

Removes tests that dialyzer does not emit warnings for optimised
and and or - those warnings could actually be helpful.
2018-06-23 09:21:15 +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 9411636d12 Move did_you_mean for undefined function error to Exception.blame 2018-06-21 18:47:42 +02:00
José Valim 5ab60299b5 Do not break assertion arguments apart if they are all quoted literals 2018-06-21 16:41:05 +02:00
José Valim 896e0664a0 Improve error message on nil dispatch 2018-06-21 15:38:04 +02:00
José Valim d2799bade3 Blame badarg on apply/3 for better error messages 2018-06-21 14:24:28 +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 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
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
Tonći Galić 1db1f28b35 Raise if piping into bitstring operator <<>> (#7725) 2018-06-04 13:41:06 +02:00
Idean f0b6727b9d Add bad digit clause to Base.decode32!/1,2 for case: :mixed (#7715)
* Add failing test for Base.decode32!/2 throwing a case error instead of an argument error (Issue #7703)

* Fix Base.decode32!/2 throwing a case error instead of an argument error when using :mixed case (Issue #7703)
2018-05-27 13:24:05 +02:00
Glauber Campinho 5b26070789 Consider possible accumulator in Stream.do_zip_step/2 (#7672) 2018-05-17 22:35:28 +02:00
Eksperimental f72dd0a0c4 Use first..last in ranges (#7675)
As opposed to left..right and x..y
2018-05-12 10:29:47 +02:00
José Valim 26d53e60a7 Better document File.stream options, closes #7671 2018-05-11 21:45:41 +02:00
José Valim 5b672b4b31 Also inflect the id from name in the Task.Supervisor child_spec 2018-05-11 12:55:23 +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
Devon Estes 33e161fe73 Add helpful error message for improperly formatted type definitions (#7650)
The original issue (#7647) was posted in a very specific context, but I
figured that this implementation would both address that issue as well
as provide helpful feedback if someone were to attempt to write types
with variables incorrectly in general, since that was what was being
raised here.

I've also added more tests to ensure
that we're catching all these cases. All the allowed cases were already
covered extensively in tests, so we're good on that front.

Resolves #7647
2018-05-07 22:39:07 +02:00
José Valim 3108265d90 Count children restarting on exit in DynamicSupervisor max_children
Closes #7655
2018-05-07 21:25:00 +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
Andrea Leopardi 5facf07200 Add a test for rescuing one of multiple exceptions
We were not testing "var in [Alias1, Alias2]" but only "var in
[Alias1]". I noticed because changing the compiler to compile that to

    var.__struct__ == Alias1 and var.__struct__ == Alias2

would still pass tests for Kernel.RaiseTest.
2018-05-04 03:01:05 -03: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 463b11edc4 Support infinity timeout on yield_many, closes #7633 2018-05-02 09:20:41 +02:00
Aleksei Magusev c0859c8714 Improve test names and regroup assertions in Inspect.BitStringTest 2018-05-01 16:49:18 +02:00
Aleksei Magusev 33367893d7 Remove duplicate assertion in Inspect.BitStringTest 2018-04-30 22:59:58 +02:00