Commit Graph
221 Commits
Author SHA1 Message Date
Jean Klingler dc6fa24edd Inline duration building in shift/2 functions (#13489)
* Inline duration building in shift/2 functions

* Rename __duration__! and define in all modules
2024-04-10 12:57:26 +09:00
Jean Klingler 98719ff200 Inline some pure functions calls (#13483) 2024-04-08 22:54:03 +09:00
José Valim d68c8d6cdd Unify handling of .. and ... 2024-02-07 12:26:39 +01:00
José Valim bc8463f5b2 Remove more test suite warnings 2023-10-31 08:05:40 +01:00
José Valim 14f3a1e372 Deprecate single quotes as charlists 2023-10-29 13:30:03 +01:00
Jean Klingler 6ee16616c0 Fix OTP 26.1 warning in tests (#12954) 2023-09-23 18:15:09 +09:00
Jean Klingler 9c0fa3cfef Warn when matching on 0.0 and generate erl AST for +/-0.0 (#12949) 2023-09-23 00:27:44 +09:00
Vinícius Müller 0349240827 Add MistmatchedDelimiterError (#12918) 2023-09-12 12:18:51 +02:00
Jean Klingler a7edd6ea47 Parser honors :static_atoms_encoder for multi-letter sigils (#12706)
* Unify sigil token generation

* Parser honors :static_atoms_encoder for multi-letter sigils

* Remove chars from token, reverse engineer from atom
2023-06-24 18:29:24 +09:00
Zach Allaun 2d65a4613b Fix column count when tokenizing escaped interpolations (#12504) 2023-03-30 22:24:23 +02:00
Andrea Leopardi c402e8336c Add support for multi-letter uppercase sigils (#12448) 2023-03-05 13:10:28 -06:00
sabiwara 2c03d5fd90 Follow-up for Erlang maybe (#12430) 2023-02-27 12:36:20 +01:00
José Valim b8c7bfa1bf Add prune_binding to Code.eval_quoted_with_env/4 2022-10-29 20:42:51 +02:00
José Valim bee0bb56be Do not emit warnings when formatting code
Closes #11595.
2022-01-26 13:37:53 +01:00
José Valim 851ac27272 Run unicode security linting on more tokens 2022-01-21 10:50:02 +01:00
José Valim e480151fe7 Add Code.Fragment.container_cursor_to_quoted/2 (#11315) 2021-10-16 15:12:09 +02:00
sabiwara 0a26aa543b Tokenizer uses static_atoms_encoder on quoted keyword keys (#11313)
Closes #11312
2021-10-15 08:10:18 +02:00
Danila Poyarkov 51ddee7b85 Allow sigil modifiers to contain digits (#11283) 2021-10-02 22:10:05 +02:00
José Valim 2a3dfa7d7e Pass annotation forward when building Erlang AST 2021-09-11 10:21:31 +02:00
José Valim 1789c1eb9b Handle OP/ARITY syntax more consistently 2021-08-27 21:39:14 +02:00
José Valim 5eb2efe543 Break Macro.Env apart (#11164)
Previously, the internal Elixir expansion pass worked directly on
Macro.Env. However, this poised an issue, if we want to track
more information in the pass, we ended up exposing it on
Macro.Env, making it larger, and potentially slowing down
operations such as __ENV__ serialization.

This commit refactors the expansion pass to work with two
structures, the Macro.Env struct and a #elixir_ex{} record.
2021-08-03 13:35:15 +02:00
José Valim 46bd3d57d9 Add operator handling to Code.cursor_context 2021-07-21 18:59:43 +02:00
Dorgan 1c8ba7489d Preserve heredoc indentation metadata (#11128) 2021-07-20 08:16:21 +02:00
José Valim 35a066dd0b Fix warning on Erlang suite 2021-06-08 08:56:10 +02:00
José Valim b44bbe536c Do not assume that literals in blocks have been normalized 2021-05-27 13:15:46 +02:00
José Valim 2a374aee71 No longer auto-sort bindings 2021-02-24 15:39:33 +01:00
José Valim 85599242fd Update erlang test helper 2021-02-24 09:50:48 +01:00
José Valim 93adad7aa4 Remove duplicated tests 2021-02-24 09:40:56 +01:00
José Valim 1656bb2b04 Properly handle keywords followed by ::, closes #10599 2021-01-02 17:41:16 +01:00
sabiwara cc8c657fbe Fix &//2 parsing issue (#10312) 2020-09-10 09:20:07 +02:00
Ivan Rublev 0ae5f4fda5 Add +++ and --- with right associativity to the list of custom operators (#9954) 2020-04-21 13:03:31 +02:00
Wojtek Mach c3752ac4df Add :indentation to sigil heredoc meta (#9725) 2020-01-14 20:45:24 +01:00
Wojtek Mach 63be6419ee Add :column to Code.string_to_quoted*/2 2020-01-12 15:41:36 +01:00
José Valim dbf8a7a9fe Use version metadata in Erlang pass 2019-11-16 02:45:55 +01:00
José Valim 08d6fe8cb8 Add parens to static remote nullary calls
test/erlang/module_test.erl have also been removed
as they have been ported elsewhere.
2019-11-08 17:59:08 +01:00
José Valim ab71fef4a9 Reduce private API surface 2019-07-29 15:20:13 +02:00
José Valim 8c5c466a71 Add literal encoder option to Code.string_to_quoted 2019-06-19 00:04:08 +02:00
José Valim d9af62f7e5 Ensure third element in location tuple is either nil or an integer 2019-05-09 10:59:13 +02:00
Tomáš Janoušek 7fa6aa7f6f Fix columns in tokenize of dot_call_op (#8995)
handle_dot already gets the column of `(` from strip_dot_space.
2019-04-29 23:34:08 +02:00
Eksperimental 266caa2f2f Use "code point" instead of "codepoint" (#8774)
That's the term it is used in the Unicode standard.
2019-02-06 11:21:03 +01:00
Glauber Campinho 2d9dece6cb 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 f6b41592e6 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
José Valim fc8de8a440 Warn on unnecessary quotes (#7838) 2018-07-10 10:27:02 +02:00
José Valim 001fa888ce Fix erlang-based tests 2018-07-09 11:22:23 +02:00
Michał Muskała 50bead0798 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
José Valim 216d6d6edf 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 e8dfef4a72 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
René Föhring 3887c7430f Fix column in :elixir_tokenizer for sigils with modifiers (#7529)
This fixes cases where :elixir_tokenizer does not account for sigil modifiers
when determining the column for the next token.
2018-04-03 13:16:02 +02:00
Glauber Campinho bfd2be892b Fix column count on heredoc tokenizer (#7486) 2018-03-25 12:37:15 +02:00
José Valim 9d40e110d9 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