Commit Graph
139 Commits
Author SHA1 Message Date
José Valim 560e721b9b Remove unused funtionality and erase pdict properly 2019-10-25 15:29:46 +02:00
José Valim b08593b9d1 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 ce5602bee1 Include file+line range in eval errors 2019-07-29 15:20:13 +02:00
José Valim b3201224b3 Reduce private API surface 2019-07-29 15:20:13 +02:00
José Valim cbc6029fec Store each compiler option directly in elixir_config, closes #9208 2019-07-18 17:13:10 +02:00
Eric Meadows-Jönsson 9b6ec7bae7 Move unreachable function check from xref to group pass (#9168) 2019-06-28 10:25:49 +02:00
José Valim f38895cebb Add literal encoder option to Code.string_to_quoted 2019-06-19 00:04:08 +02:00
José Valim 776225f4e1 Add end of expression token information
This also renames pairing_metadata to token_metadata,
as it mostly contains information about related tokens
and not necessarily pairs.
2019-06-18 00:25:22 +02:00
José Valim faefb0b882 Exposing pairing metadata (#9146)
This introduces five new metadata nodes:

  * `do` - contains metadata about do location in a function call with
    `do/end` blocks
  * `end` - contains metadata about end location in a function call with
    `do/end` blocks
  * `closing` - contains metadata about the closing pair, such as a `}`
    in a tuple or in a map, or such as the closing `)` in a function call
    with parens
  * `eol` - is set to true when the opening pair, such as `{` or `(`, are
    followed by the end of the line
  * `delimiter` - contains the opening for sigils (such as `"{"`, `"/"`,
    etc)
2019-06-17 16:38:52 +02:00
Daniil Fedotov 145b7019ae Make regexes fall back to binary matching on incompatible runtime version (#9040)
Regexes are precompiled to binary values during code compilation.
These binary values may be incompatible between different PCRE versions
and OS endianness. This makes code less portable to achieve slight
performance improvement.

PCRE version and endianness are parts of Regex structure and may be
checked in runtime.

This commit adds this check and makes regex execution fall back 
to binary matching if versions are incompatible.

This slightly reduces performance (around 5% for simple regexes) for
compatible versions because there is an additional version read.
Also for incompatible versions it's as fast as binary matching.
2019-05-21 09:34:55 +02:00
José Valim 10fd316439 Delegate Erlang/OTP version check to Elixir 2019-05-15 17:23:26 +02:00
José Valim 3673849e36 Use System.no_halt/1 instead of Process.sleep/1 in mix run
Otherwise :init.get_status will stay in
{:starting, :started} forever.
2019-03-27 00:17:21 +01:00
José Valim 88338bb99b Take nil lexical_tracker into account 2019-03-14 21:22:59 +01:00
José Valim b80ee75e2d Pass lexical tracker forward if available, closes #8893 2019-03-14 20:42:02 +01:00
José Valim 0c1df34645 Standardize more TODOs 2018-12-21 13:42:54 +01: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
Michał Muskała ffb931a5ac Fix all compiler warnings (#7992) 2018-07-27 16:42:24 +02:00
José Valim 7ea56bc09c Tiny perf improvements to the compiler 2018-07-23 11:23:50 +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 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
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
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
Glauber Campinho 4398927789 Erase elixir_parser_columns from the process dictionary after use (#7601) 2018-04-27 00:39:18 +08:00
José Valim 219c6cc867 Move unused_vars check to Elixir land
This gives us better control over when and how unused variables are printed.

As a result, we are able to emit unused variable warnings in situations
we could not before. This also opens up the way for us to remove a
dependency on erl_lint and track types information, which allows us to
speed up compilation times about 5% and allow us to emit more performant
code in some situations.
2018-01-20 19:45:48 +01:00
José Valim f99bb7c0e5 Process variable versioning on Elixir pass 2018-01-20 19:42:08 +01:00
José Valim b9591267dc Replace Code.load_file/2 by Code.compile_file/2 (#7201)
Currently there is no way to compile a file without leaving
footprints on the system. Plus, the term load_file/2 is very
confusing as loaded is the notation used by modules.

This commit focuses the whole loaded aspect of files exclusively
on require_file/2 (and renames two functions accordingly) and
introduces compile_file/2 which is semantically simpler than
load_file/2.
2018-01-13 22:04:22 +01:00
José Valim b87989e702 Support columns: true in string_to_quoted, closes #3554 2017-10-25 11:02:53 +02:00
José Valim 34651f1034 Format errors_test.exs 2017-10-12 09:35:58 +02:00
José Valim 906a432b41 Check formatting is equivalent on travis 2017-10-08 19:28:36 +02:00
José Valim 455c2c3f3b Rely on side effects for preserving comments
The previous implementation would not lead to parsing
errors in interpolations since code inside interpolation
is parsed immediately.
2017-10-05 13:27:25 +02:00
José Valim 7a556b8f26 Add string_to_tokens and tokens_to_quoted 2017-09-24 23:15:19 +02:00
Ivan Kozik 75150ec7eb Fix more typos and spelling errors (#6530) 2017-09-01 10:20:53 +02:00
José Valim 97ece16b11 Add more formatter metadata 2017-08-30 17:21:17 +02:00
José Valim 100ea4e73a Add more information about system start and shutdown
Closes #6479.
2017-08-19 21:37:41 +02:00
José Valim 579f93bcc7 Ensure elixir_erl:debug_info/4 does not require elixir running (#6401) 2017-07-29 17:27:05 +02:00
José Valim 22a7f7894c Remove erlang:get_stacktrace() warning 2017-07-20 19:19:20 +02:00
José Valim b21a1f1f85 Disable warning of IEx commands via match_vars := apply 2017-07-10 02:13:26 +02:00
José Valim 1a2cd08e0a Add IEx.Pry infrastructure 2017-07-09 23:01:22 +02:00
Alex Jiao d7d47ff640 Add wrap_literals_in_blocks option to parser (#6263) 2017-06-28 10:45:55 +02:00
José Valim 43a4720b1a Start v1.6.0-dev 2017-06-25 13:49:50 +02:00
José Valim 3c9b191ec1 Do not rely on on_load because it breaks releases 2017-05-29 15:50:06 +02:00
José Valim 9873e4239f Add non-quoted Unicode atoms and variables (#6158)
It follows Unicode Annex #31.

See the Unicode Syntax document for a more in-depth reference.
2017-05-27 22:43:05 +02:00
José Valim 07d40af48f Add Exception.blame/3 and Exception.blame_mfa/3 (#6127) 2017-05-22 23:58:14 +02:00
José Valim ed58508dfe Add Regex.recompile/1 and Regex.recompile\!/1 2017-05-07 11:17:35 +02:00
Eksperimental 7357f56526 Add nonempty_charlist/0 built-in type (#5879) 2017-03-16 09:46:19 +01:00
José Valim 102a8a3fa8 Add elixir_erl_compiler 2017-02-23 13:15:26 +01:00
Aleksei Magusev 84b67b5b95 Rename elixir_exp module to elixir_expand 2017-02-19 21:57:50 +01:00
Aleksei Magusev a729847db6 Rename m/2 helper macro to key/2 in the main header file 2017-02-19 21:56:05 +01:00
José Valim e7e0d512ff Move erlang modules to new erl namespace 2017-02-19 20:20:59 +01:00