Commit Graph
1771 Commits
Author SHA1 Message Date
José Valim 4a5bcaaa8e Ensure eval_quoted properly resets last definition, closes #8261 2018-10-09 20:49:38 +02:00
José Valim 1ca25436be Use the no_spawn_compiler_process in more recent release
See https://github.com/erlang/otp/pull/1972.
2018-10-03 14:02:46 +02:00
José Valim 159e9655d5 Bypass erl_lint and spawn compiler processes manually (#8241)
This speeds up the Elixir compiler from 5-10% as we no
longer do duplicate work on erl_lint and expand_records.
We also avoid the copying of messages by controlling
exactly when the compiler spawns new processes.
2018-10-02 11:18:44 +02:00
Glauber Campinho 741dfda9f4 Let the undefined function error be performed in Elixir-land (#8231)
Refers to #5800
2018-10-01 12:22:38 +02:00
Fernando Tapia Rico e1e096ab2e Warn on underspecified opaque types (#8232)
Refers to #5800

Performs the erl_lint check "underspecified_opaque, {TypeName, Arity}}" in Elixir.

After reading the Erlang/OTP codebase, it seems an "underspecified opaque" is an opaque type of arity 0 with a spec of "term" or "any".
2018-09-28 10:58:31 +02:00
Glauber Campinho 3fcc9241db Optimizes multiple :maps put and merge operations (#8223)
Optimizes :maps.put/3 to a VM operation instead of a remote call, including nested calls to it.
It does the same for :maps.merge/2 with a simple map on the right side.

Closes #7353
2018-09-28 08:40:27 +02:00
Andrea Leopardi e0d1c2e4ca Fix error messages for some "try" errors (#8220)
Related to #8219.

The errors could come from "def" as well (this is stored in the :origin 
key in the metadata).
2018-09-23 21:08:10 +02:00
Andrea Leopardi 9e302cbd01 Forbid using only the "else" clause in "try" (#8219)
Closes #8146.

Now using "else" without a "rescue", "catch", or "after" in "try" 
expressions is not allowed anymore.
2018-09-23 12:09:47 +02:00
Glauber Campinho f332273228 Use head definition meta to warn about unused args (#8198)
Fixes #8184
2018-09-16 10:44:26 +02:00
José Valim 050f10e849 Improve message for unnecessary quotes, closes #8197 2018-09-14 22:05:23 +02:00
Glauber Campinho fad27bacab Remove Guard test tuple_size(...) can never succeed dialyzer warning on try (#8196)
Fixes #8157
2018-09-14 21:42:30 +02:00
Fernando Tapia Rico 6b5c167d23 Raise errors with duplicated entries on import (#8188)
Fixes #8187
2018-09-12 10:43:50 +02:00
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