Commit Graph
3715 Commits
Author SHA1 Message Date
José Valim 8ec9860a4e Ensure generated docs can be overridden without explicit clause 2020-04-25 00:35:04 +02:00
José Valim 9b5cafe72a Bring back String.normalize and fix infinite loop 2020-04-23 13:35:49 +02:00
Ivan Rublev 29f29419a2 Add +++ and --- with right associativity to the list of custom operators (#9954) 2020-04-21 13:03:31 +02:00
Pablo Costas 110dfe67aa Fix tokenizer emitting repeated warnings in the REPL (#9924)
Now we only emit tokenizer warnings upon tokenization success.
2020-04-10 00:48:49 +02:00
José Valim 8742096f77 Do not emit warwnings for injected funs 2020-04-07 18:23:04 +02:00
José Valim 3d3e233255 Refactor binary handling 2020-04-05 20:15:50 +02:00
José Valim 68ad287a58 Improve error message for nested binaries in match without specifiers, closes #9908 2020-04-04 12:35:46 +02:00
José Valim 5e3ef21c24 Show Erlang docs directly in the shell (#9843) 2020-03-28 20:43:45 +01:00
Wojtek Mach 97aef3c5db Deprecate non-atom keys on put_env, get_env, fetch_env*, delete_env (#9915)
Typespecs already required an atom key but it was never enforced by
code. We're doing this because we eventually would like to support
passing a _path_ like:

    Application.get_env(:myapp, [:key, :foo, :bar])

and this way we will be consistent with recently added
`Application.compile_env/3`.
2020-03-28 13:02:23 +01:00
José Valim 8491f0dc74 Fix improper regex use, closes #9914 2020-03-28 10:49:23 +01:00
Wojtek Mach 2701169b1e Use new ExDoc extras auto-links (#9912) 2020-03-27 00:05:48 +01:00
José Valim f3806f82af Revert "Use an empty keyword list instead of nil for empty definitions"
Closes #9910

This reverts commit 4477115675.
2020-03-24 20:21:01 +01:00
José Valim 1a4efb79a1 Reduce the newlines count when they are immediately followed by a comment, closes #9873 2020-03-13 11:27:06 +01:00
Hans Bernhard Gödeke 593b3083c4 Warn when @doc attribute is replaced across clauses
Closes #9883
Closes #9888
2020-03-13 09:44:40 +01:00
José Valim d375989b28 Do not warn on nullary calls without parens 2020-03-12 13:11:11 +01:00
Boris 862b6ebfee Add default and enforce keys in Version struct (#9886)
String.Chars.to_string/1 was failing due to unexpected `nil` value in `pre` field.
2020-03-09 19:59:23 +01:00
Eric Meadows-Jönsson 31818a36e6 Do not propagate context between clauses (#9869) 2020-03-03 08:19:20 -08:00
José Valim 6055db482a Add start and stop events to compilation tracers, closes #9868 2020-03-02 14:36:19 +01:00
José Valim 7052f2b31d Remove race condition with cli test 2020-03-01 11:59:03 +01:00
Wojtek Mach 561338d5e6 Return [{mod, bin}] from Code.compile_file/2, require_file/2, load_file/2 (#9864)
This was the documented behaviour on 1.9 that was broken on v1.10: (version `git` is this branch)

    $ cat a.ex
    defmodule A, do: nil

    $ for v in 1.9.4-otp-22 1.10.2-otp-22 git; do asdf local elixir $v && echo $v; elixir -e 'IO.inspect Code.compile_file("a.ex")'; done
    1.9.4-otp-22
    [{A, <<70, 79, ...>>}
    1.10.2-otp-22
    [{A, %{attributes: [], ...}]
    git
    [{A, <<70, 79, ...>>}

    $ for v in 1.9.4-otp-22 1.10.2-otp-22 git; do asdf local elixir $v && echo $v; elixir -e 'IO.inspect Code.require_file("a.ex")'; done
    1.9.4-otp-22
    [{A, <<70, 79, ...>>}]
    1.10.2-otp-22
    [{A, %{attributes: [], ...}]
    git
    [{A, <<70, 79, ...>>}]

    $ for v in 1.9.4-otp-22 1.10.2-otp-22 git; do asdf local elixir $v && echo $v; elixir -e 'IO.inspect Code.load_file("a.ex")'; done
    1.9.4-otp-22
    [{A, <<70, 79, ...>>}]
    1.10.2-otp-22
    warning: Code.load_file/1 is deprecated. Use Code.require_file/2 or Code.compile_file/2 instead
      nofile:1

    [{A, %{attributes: [], ...}]
    git
    warning: Code.load_file/1 is deprecated. Use Code.require_file/2 or Code.compile_file/2 instead
      nofile:1

    [{A, <<70, 79, ...>>}]
2020-03-01 00:50:14 +01:00
Calvin Buckley 651375ddb2 Fix File module rename tests on PASE (#9860)
IBM i PASE implements rename in a slightly weird way due to it
wrapping the native syscall. Expect this in the File module's
rename test when expecting an error. Fixes #9858.

This should be the behaviour documented (different from
AIX, which it's emulating, and strange for POSIX):

https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_74/apis/renameun.htm
2020-02-28 19:37:16 +01:00
José Valim 9d56a019ee Add application tracers to Mix
This tracer is used to validate that all modules being invoked
in an application belongs to an application that is currently
listed as a dependency. This will help enforce umbrella application
boundaries and help users discover when they depend on Elixir and
Erlang libraries without declaring them upfront.

Thanks to @sasajuric for the proof of the concept and insights
that made this feature possible.

Closes #9847.
2020-02-28 16:05:34 +01:00
José Valim 351cff9d95 Fixes for Erlang/OTP 23 2020-02-26 12:06:08 +01:00
Eric Meadows-Jönsson 184b71956d Fix float binary type specifier (#9844) 2020-02-25 20:54:11 +01:00
Wojtek Mach ca33a6c8a9 Code.fetch_docs/1: Support reading from doc/chunks/*.chunk (#9838) 2020-02-25 09:40:46 +01:00
José Valim 3c9e004ded Rewrite and deprecate System.stacktrace 2020-02-24 21:31:37 +01:00
José Valim da9b901457 Pass the documentation format to IO.ANSI.print/3 2020-02-24 14:40:03 +01:00
José Valim 1a2f5e5828 Fix the build 2020-02-24 13:04:46 +01:00
José Valim 276bd54f45 Also use markdown docs formatter when ANSI is disabled 2020-02-24 13:03:50 +01:00
José Valim 413f608ed4 Do not show binary types if they are inferred 2020-02-23 10:26:11 +01:00
José Valim 182f16b76f Avoid false positives on capture warning 2020-02-20 21:50:47 +01:00
Eric Meadows-Jönsson 0f85b397da Add checking of patterns in body (#9828) 2020-02-20 16:46:06 +01:00
José Valim af4d6c3731 Revert "Support import Mod, only: :sigils (#9822)"
It will be moved to the current multi-letter sigils PR.

This reverts commit 26adc8db3d.
2020-02-19 10:42:48 +01:00
Wojtek Mach 26adc8db3d Support import Mod, only: :sigils (#9822) 2020-02-17 16:58:09 +01:00
Wojtek Mach 711f346a44 Fix error message for import :except option (#9819)
Before this patch we had:

    iex> import Kernel, except: :macros
    ** (CompileError) iex:1: invalid :except option for import, expected value to be an atom :functions, :macros, or a list literal, got: :macros
        (elixir 1.11.0-dev) src/elixir_import.erl:84: :elixir_import.calculate/6
        (elixir 1.11.0-dev) src/elixir_import.erl:24: :elixir_import.import/4
2020-02-16 17:35:15 +01:00
José Valim 5984c6cc29 Revert "Warn on use of non-match argument to with/1 (#9784)"
There are too many false negatives to make this warning worth it.

This reverts commit 35665e7aac.
2020-02-15 22:02:40 +01:00
José Valim ad728a48ed Only escape contents outside of interpolation, closes #9812 2020-02-12 20:51:51 +01:00
José Valim 75e58e3ddc Do not crash on fake down messages on stream monitor, closes #9803 2020-02-12 18:31:17 +01:00
José Valim 4f1f5b8a47 Do not write files to disk if warnings as errors was triggered, closes #9808 2020-02-12 18:00:05 +01:00
Eric Meadows-Jönsson 27bd9ffcc6 Optimize Version.match?/2 and Version.compare/2 (#9807)
Pattern matching turns out to be faster than using matchspecs.

string = "~> 1.2.3 and ~> 1.0"
requirement = Version.parse_requirement!(string)
compiled_requirement = Version.compile_requirement(requirement)
new_requirement = Version.new_requirement(string)

versions =
  for major <- 1..10,
      minor <- 1..10,
      patch <- 1..10,
      pre <- [[], ["dev"]],
      do: %Version{major: major, minor: minor, patch: patch, pre: pre, build: nil}

Benchee.run(
  %{
    "old" => fn -> Enum.map(versions, &Version.match?(&1, requirement)) end,
    "old & compiled" => fn -> Enum.map(versions, &Version.match?(&1, compiled_requirement)) end,
    "new" => fn -> Enum.map(versions, &Version.new_match?(&1, new_requirement)) end
  },
  time: 10,
  memory_time: 2
)

Operating System: macOS
CPU Information: Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
Number of Available Cores: 12
Available memory: 16 GB
Elixir 1.11.0-dev
Erlang 22.0

Benchmark suite executing with the following configuration:
warmup: 2 s
time: 10 s
memory time: 2 s
parallel: 1
inputs: none specified
Estimated total run time: 42 s

Benchmarking old & compiled...
Benchmarking new...
Benchmarking old...

Name                   ips        average  deviation         median         99th %
new                 5.93 K      168.77 μs    ±11.60%      165.99 μs      266.99 μs
old & compiled      1.18 K      849.40 μs     ±7.78%      834.99 μs     1177.37 μs
old               0.0400 K    25012.15 μs     ±2.98%    24798.47 μs    27617.74 μs

Comparison:
new                 5.93 K
old & compiled      1.18 K - 5.03x slower +680.63 μs
old               0.0400 K - 148.20x slower +24843.38 μs

Memory usage statistics:

Name            Memory usage
new                125.05 KB
old & compiled     157.52 KB - 1.26x memory usage +32.46 KB
old                250.99 KB - 2.01x memory usage +125.94 KB

**All measurements for memory usage were the same**
2020-02-11 14:28:40 +01:00
José Valim b2ee70ee74 Unpack extra guards from with matches, closes #9801 2020-02-09 18:15:21 +01:00
Wojtek Mach 480c3a30be Fix unused variable warnings (#9790) 2020-02-06 20:27:47 +01:00
José Valim 3ea9abaca0 Add missing :erlang.size/1 guard, closes #9789 2020-02-06 18:44:49 +01:00
Jesse Van Volkinburg 35665e7aac Warn on use of non-match argument to with/1 (#9784)
Closes #9764.
2020-02-05 13:14:55 +02:00
José Valim 53dbf7083e Add Code.can_await_module_compilation?/0 (#9777) 2020-02-05 11:39:08 +01:00
José Valim b9e2d38bb6 Only warn for commas at the end of words 2020-02-04 13:25:02 +01:00
José Valim c31958aa17 Add tests for timer and interval with infinity 2020-02-03 12:42:05 +01:00
Fernando Tapia Rico 02abfb75fc Remove unneeded code in test (#9778) 2020-02-03 11:23:51 +01:00
José Valim 1ce5b6a311 Run formatter 2020-02-03 09:46:48 +01:00
José Valim 8715a7215e Remove redundant process test
The previous test already checked trapping exits
returns the exit message.
2020-02-03 09:09:00 +01:00