Commit Graph
1759 Commits
Author SHA1 Message Date
José Valim cd439540fc Revert wrong warning on parse_transforms removal 2018-09-07 10:04:57 -07:00
Glauber Campinho 3d9d799a91 Fix invalid expansion for remote (#8154)
When left side is expanded but become invalid, the expansion result in the AST leaking for the user, for example:

```
iex(1)> __ENV__.line.foo
{{:., [line: 1], [1, :foo]}, [line: 1], []}
```

This checks the expanded left to ensure that it's safe
2018-09-06 04:43:57 -07:00
Fernando Tapia Rico b59d280a79 Use imported function in elixir_parser.yrl (#8151) 2018-08-29 14:19:50 +02:00
Eksperimental cdd9dae8b4 "Fall back" the verb is 2 separate words (#8131) 2018-08-27 12:10:22 +02:00
Fernando Tapia Rico caf62d5355 Use ETS instead of ets in documentation (#8099) 2018-08-17 00:35:49 +02:00
José Valim 36718cb41b Correctly tag struct invocations, closes #8097 2018-08-16 23:56:47 +02:00
José Valim 6d4c581cf2 Improve unused variable warnings (#8071) 2018-08-15 12:13:53 +02:00
Fernando Tapia Rico df683c1d72 Fix arity of try/1 in :elixir_import.special_form (#8079)
Fixes #8078
2018-08-14 12:56:33 +02:00
Glauber Campinho 495d1646b2 Small optimization on elixir_bitstring:expand/4 (#8074)
`elixir_env:mergea(EV, EC)` is always equivalent to `EV` so we can avoid the operation.
Similar to #8069
2018-08-12 10:05:59 +02:00
José Valim 4f84f1bf2f Ensure Macro.expand/2 does not change the meaning of interpolations 2018-08-11 20:42:24 +02:00
Glauber Campinho 2e222ee724 Small optimization on expand_args/2 (#8069)
`elixir_env:mergea(EV, EC)` is always equivalent to `EV` so we can avoid the operation
2018-08-10 17:48:43 +02:00
José Valim 78ed8a55a3 Only add context if vars hygiene is enable 2018-08-09 10:33:15 +02:00
José Valim 5866b9da5c Do not allow atoms inside maps 2018-08-09 10:33:15 +02:00
José Valim 827f86b19c Make bind_quoted aware of variable contexts 2018-08-08 19:16:57 +02:00
José Valim 7fba39dfe0 Do not inline non-BIFs 2018-08-06 00:08:42 +02:00
José Valim ae6668f846 Repeat the variable name at the end for convenience 2018-08-05 21:25:10 +02:00
Fernando Tapia Rico 1e9446a2bb Minor improvements in match operators code (#8048)
Minor things I spotted while reading https://github.com/elixir-lang/elixir/pull/8043 :)
2018-08-05 10:57:15 +02:00
Fernando Tapia Rico c4427d725b Fix unused variable warning (#8049) 2018-08-05 10:36:32 +02:00
José Valim a2d81db23b Delete counter for vars in nested quotes (#8042)
Consider the following example:

    defmodule NestedQuote do
      defmacrop macro(arg) do
        quote bind_quoted: [arg: arg] do
          quote bind_quoted: [arg: arg], do: String.duplicate(arg, 2)
        end
      end

      defmacro __using__(_) do
        quote do
          def test do
            unquote(macro("foo"))
          end
        end
      end
    end

    defmodule UseNestedQuote do
      use NestedQuote
    end

It has two macro expansions, one inside __using__/1 when it invokes
macro/1, and another when used. The issue, however, is that the
`arg` of `String.duplicate(arg, 2)` gets tagged with the context
of `macro/1` but it should be tagged with the context of `__using__`
since it is a quote inside a quote. This patch addresses this.
2018-08-04 16:46:49 +02:00
Michał Muskała 887e8f2633 Rewrite match operators in elixir (#8043)
Until now, we left rewriting operators in matches to Erlang. This forced
us to inherit Erlang semantics, especially for the ++ operator, that
only allows lists of integers on the left side inside matches. The new
implementation just rewrites this operator regular improper list matching.
Additionally we rewrite matching on -/1 and +/1 operators to number
literals - matching with those operators and variables was never
supported.

Additionally do a bit of housekeeping and refactor code around rewriting
and validating remote calls.
2018-08-04 15:14:13 +02:00
Michał Muskała d76f150274 Use scoped deterministic counters in AST expansion
Signed-off-by: José Valim <jose.valim@plataformatec.com.br>
2018-08-04 12:56:01 +02:00
José Valim f2415dd06c Revert "Use deterministic counters in AST expansion"
Unfortunately it is common to have macros that invokes macros
from other modules, leading to mixed quoted expressions causing
the counters to be mixed.

We would need to scope the counters to the caller.

This reverts commit f04f46c49d.
2018-08-04 12:29:03 +02:00
José Valim 02d9b4fbcc Use list_to_bitstring so we don't have to track binaries (#8036)
This speeds up comprehensions and remove dialyzer warnings.

Closes #8001
2018-08-04 00:05:28 +02:00
Mike Buhot c096508f37 Allow :raw option in File.exists?, regular? and dir? (#8028) 2018-08-03 11:38:45 +02:00
Tan Jay Jun 103502354c Fix error typo in elixir_bitstring.erl (#8030)
[ci skip]
2018-08-02 15:02:17 +02:00
Christian Wesselhoeft f40f21195a Change error message for calling missing function in a guard (#8026) 2018-08-01 18:19:26 +02:00
Michał Muskała ffb931a5ac Fix all compiler warnings (#7992) 2018-07-27 16:42:24 +02:00
José Valim 4d7003e760 Rename definition header to function head 2018-07-26 21:27:48 +02:00
Fernando Tapia Rico 6d0f78d3bd Validate @on_load function in Elixir (#7973) 2018-07-26 16:57:35 +02:00
Michał Muskała 691460a6e6 Fast-track quoting lists with disabled unquote 2018-07-25 00:10:02 +02:00
Michał Muskała 3803712e0a Don't maintain order in env.vars 2018-07-25 00:10:02 +02:00
Michał Muskała 656ecdf5ef Optimise var building 2018-07-25 00:10:02 +02:00
Michał Muskała 335cfdbcad Separate testing for unquotes from escaping 2018-07-25 00:10:02 +02:00
Michał Muskała f04f46c49d Use deterministic counters in AST expansion
When the module is being compiled, we use deterministic counters instead
of random ones. This should help with most cases of undeterministic
source code or .beam files.

Closes #7955
2018-07-25 00:10:02 +02:00
Michał Muskała 0b816eb4e1 Refactor elixir_quote:linify 2018-07-25 00:10:02 +02:00
Michał Muskała 4229536799 Inline construction of remote erlang calls in compiler 2018-07-25 00:10:02 +02:00
José Valim 7ea56bc09c Tiny perf improvements to the compiler 2018-07-23 11:23:50 +02:00
José Valim 34befaaa36 Allow to prune metadata while escaping (#7949)
We use this option in ExUnit as we are escaping
the code to eventually convert it to a string
representation and therefore the metadata is not
relevant.
2018-07-21 12:56:07 +02:00
José Valim 95ec1be78a Clean up private elixir_config API 2018-07-19 23:27:52 +02:00
José Valim 2ff3266814 Throttle system warnings per location 2018-07-19 23:27:52 +02:00
Jean-Philippe Cugnet 3b030b009e Fix a typo in the unnecessary quotes warning (#7934)
[ci skip]
2018-07-19 19:44:58 +02:00
Fernando Tapia Rico ae15d1822f Check duplicated @on_load attributes (#7921) 2018-07-18 19:34:31 +02:00
Łukasz Samson 7ea42588ce Add Kernel.ceil/1 and Kernel.floor/1 buildins (#7888)
Fixes https://github.com/elixir-lang/elixir/issues/7882
2018-07-13 12:54:09 +02:00
Michał Muskała 06b5eae89f Compile protocols in elixir syntax (#7832)
This siwtches protocol compilation to happen on the epxnaded Elixir AST
instead of the Erlang AST. This is slightly less complex and opens
possibility for easy "partial" compilation of protocols.

Additionally instead of rewriting specs on consolidation, this marks the
functions that end-up being rewritten with @dialyzer :nowarn_function to
disable overly eager dialyzer warnings.
2018-07-12 14:43:16 +02:00
Michał Muskała 15fd691a88 Use map syntax in comprehensions instead of maps:put/3
Signed-off-by: José Valim <jose.valim@plataformatec.com.br>
2018-07-12 13:30:29 +02:00
José Valim 54cb02c240 Rely on Erlang/OTP normalization which is faster 2018-07-12 13:28:58 +02:00
José Valim 94f3d60a26 Hard deprecate previously deprecated APIs 2018-07-12 12:44:03 +02:00
José Valim 35ac568044 Require Erlang/OTP 20+ 2018-07-12 12:12:00 +02:00
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