Commit Graph
4141 Commits
Author SHA1 Message Date
José Valim de7abfeb4e Handle block and multiline clauses without line length 2021-12-11 10:19:06 +01:00
José Valim dabfc58780 Revert "Simplify inspect testing structure"
The particular error message requires OTP 24.

This reverts commit 7bac166dd4.
2021-12-10 13:09:42 +01:00
José Valim 7bac166dd4 Simplify inspect testing structure 2021-12-10 11:13:54 +01:00
José Valim 99006eb081 Do not cursor sigil after dot 2021-12-10 09:27:45 +01:00
felipe stival b13a9977d9 Change approach: never show error if line is empty (#11466) 2021-12-10 09:27:25 +01:00
José Valim e89bbdfb29 Handle improper lists on apply, closes #11465 2021-12-09 21:22:39 +01:00
José Valim 1a9e59cd4d Deprecate use Bitwise and ~~~
Use `import` instead.
2021-12-09 21:08:57 +01:00
Dorgan 2c8a9ddf53 Fix formatting of lists in module attribues (#11462) 2021-12-08 23:51:26 +01:00
José Valim 611139ef3e Fix codepoint byte counting in slice, closes #11461 2021-12-08 23:50:38 +01:00
Chris Miller 5b8ccc55e4 Add Stream.duplicate/2 (#11456) 2021-12-07 20:42:56 +01:00
José Valim af0fd81606 Make sure --version flag halts elixir and iex, closes #11453 2021-12-07 08:18:19 +01:00
José Valim aa41c88086 Do not deprecate URI.parse/1
Closes #11450.
2021-12-06 14:58:01 +01:00
José Valim 822837e188 Add clarifications to Access error message 2021-12-05 20:20:37 +01:00
Parker Selbert 1f0422ac2e Specific base typespecs (#11449)
* Use specific options for base option typespecs

Each function had `keyword` as the option type, which didn't help guard
against typos or mismatched options.

* Fix padding use in encode/decode identity test
2021-12-05 19:50:22 +01:00
José Valim c4527b3ff4 Add Macro.classify_atom/1 and Macro.inspect_atom/2 (#11446)
Today the formatter still uses some private APIs
and this commit aims to expose some of them.
In particular, Macro.classify_atom/1 was added to
expose if an atom is an alias, an identifier, quoted,
or unquoted.

Note that the API does not say anything about
operators, since they can fall within three distinct
categories:

  * unquoted and callable, such as, `+`, `-`, and
    most operators

  * unquoted and not callable, such as, `.`, `..`,
    and `..//`, which would be ambiguous when used
    as `Module.OP()`

  * quoted but callable, such as `::`, which is
    ambiguous in the atom syntax but not as calls

This information still remains private, especially
because most times operators are used, we often still
want to learn about their precedence too.

We also exposed `inspect_atom/2` with three
distinct clauses to cover the different scenarios
atoms can be inspected at runtime and in source
code.
2021-12-05 15:02:06 +01:00
José Valim 4dd1301d03 Warn on ::: to avoid ambiguity
The formatter already rewrote it to :"::" since
its conception.
2021-12-05 10:40:19 +01:00
José Valim c2578c9370 Add Map.from_keys/2 and Keyword.from_keys/2 (#11432)
The map operation is optimized since Erlang/OTP 24+
as we don't need to do an additional traversal to
create tuples.
2021-12-02 21:51:22 +01:00
Dorgan 2dede8ea2b Fix normalization of kw list in blocks (#11431) 2021-12-02 08:21:59 +01:00
Eksperimental a1e794fce5 Improve Version.compile_requirement/1 (#11427) 2021-11-30 11:25:19 +01:00
José Valim b131f87464 Warn if an outdated lexical tracker is given on eval 2021-11-26 23:00:18 +01:00
José Valim 3b93c6f969 Move syntax errors to parser file 2021-11-26 21:02:07 +01:00
José Valim adab68df21 Do not print control chars as unexpected tokens 2021-11-26 21:02:07 +01:00
Eric Meadows-Jönsson 0fd981a498 Add Version.to_string/1 (#11422) 2021-11-26 15:38:52 +01:00
José Valim 209688fc52 Handle outdated anonymous functions in Erlang/OTP 25 (#11421) 2021-11-26 06:47:10 +01:00
José Valim f5208a39a3 Emit checker warnings on compile_string/compile_quoted, closes #11417 2021-11-25 21:14:14 +01:00
José Valim 4a88be86f8 Preserve opts while formatting failed inspect struct
Also make formatting consistent.
2021-11-25 18:11:05 +01:00
Eksperimental 6fa5018f9e Improve user experience when there is a faulty Inspect implementation (#11403) 2021-11-25 17:41:03 +01:00
José Valim d0e4af9353 Skip errors on head of generated clauses, closes #11407 2021-11-21 19:33:14 +01:00
Rudolf d6b0fcacb0 Add Registry.count_select/2 (#11405) 2021-11-20 14:35:02 +01:00
José Valim 3b52a04354 Warn on trailing commas on calls, closes #11399 2021-11-19 11:46:46 +01:00
Eksperimental 916cf08069 Make all Inspect tests asyncronous (#11402) 2021-11-18 23:09:49 +01:00
Dorgan 2270c95ab3 Fix normalizer not preserving user choice on module attribute lists (#11397) 2021-11-17 15:05:37 +01:00
José Valim 39121adb57 Reject bidirectional formatting characters (#11391) 2021-11-15 21:08:37 +01:00
José Valim a618213616 Support escaping of terminators in uppercase sigils heredocs for consistency, closes #11390 2021-11-15 14:21:12 +01:00
José Valim 58455c1872 Do not raise on variable looking like an empty tuple 2021-11-13 12:37:01 +01:00
Eksperimental 3947ab7117 Allow Application.compile_env* to accept attributes (#11383) 2021-11-11 22:04:20 +01:00
José Valim 34368b2680 Do not crash on duplicate bindings, closes #11378 2021-11-10 19:27:53 +01:00
José Valim e0c60c68a0 Do not extract comments without a newline 2021-11-08 18:01:25 +01:00
José Valim 64c2248aa4 Use keyword syntax by default in tuple formatting 2021-11-08 17:25:25 +01:00
Guillaume Duboc f9ec2e7c5b Fix formatting of map-like types in warnings (#11351)
This came up in issue #11204:

When emitting a warning for a type unification error,
the compiler overly simplifies the formatting of types
when these are maps or unions of maps.

To address this, we recursively check for maps inside
of a union type when comparing it to another map-like type.
2021-11-07 09:30:08 +01:00
José Valim 6ce87e28b9 Fix regression on URI.parse/1, closes #11363 2021-11-04 08:46:16 +01:00
Tyler A. Young 368c311077 Improvements to Enum.slide/3 (#11361)
- Support negative insertion indices
- Give a clear RuntimeError, rather than a baffling CondClauseError, when you ask for an insertion point that matches the last element of your range
2021-11-03 23:41:57 +01:00
Dorgan 34f32ef8a0 Keep keyword format of tuple last element (#11354) 2021-10-31 22:26:59 +01:00
Tyler A. Young c1d2bc7cc4 Add Enum.slide/3 (#11349) 2021-10-31 12:24:35 +01:00
felipe stival c5269a5230 Typespecs: show expanded module name on inexistent struct field error (#11353)
Closes #11352.
2021-10-30 09:39:44 +02:00
Maarten van Vliet b166e8e184 Pass sigil/modifiers through to formatter (#11348)
This allows the formatter plugins to format content
based on whether it's a file or a sigil being formatted.
The modifiers could be used for additional options.
2021-10-26 14:06:06 +02:00
José Valim e5e5170426 Use algebra concat instead of binary concat 2021-10-25 23:22:00 +02:00
Michał Łępicki dec273346a Ensure Code.string_to_quoted input only needs the List.Chars protocol (#11344) 2021-10-25 22:07:55 +02:00
José Valim f2ad9823d8 Only consider StartColumn on first line 2021-10-25 16:33:16 +02:00
felipe stival edcb9096d5 Show code snippet on syntax and token missing errors (#11332)
Closes #11280.
2021-10-25 16:18:29 +02:00