Commit Graph
8707 Commits
Author SHA1 Message Date
José Valim b4e0ce55db Shutdowns can be any term, closes #9878 2020-03-07 00:20:16 +01:00
Fernando Tapia Rico 9e2cf0b12b Document version of :start/:stop events (tracers) (#9871) 2020-03-03 20:09:30 +01:00
Eric Meadows-Jönsson d3c673db74 Do not propagate context between clauses (#9869) 2020-03-03 08:19:20 -08:00
José Valim cde1f68392 Add start and stop events to compilation tracers, closes #9868 2020-03-02 14:36:19 +01:00
José Valim 1eab8fa9e6 Remove race condition with cli test 2020-03-01 11:59:03 +01:00
José Valim 330f1c64ef Unify compilation entry point in the compile Mix task 2020-03-01 11:50:34 +01:00
José Valim 2034babbd7 Fix metadata link 2020-03-01 10:40:55 +01:00
Hassan Shaikley a6851a9d9e Documentation wording improved for Supervisor.Spec moduledoc (#9866) 2020-03-01 10:27:32 +01:00
Hassan Shaikley ceff221583 Documentation wording improved for List.Chars moduledoc (#9865) 2020-03-01 10:26:19 +01:00
Wojtek Mach f6fd284e56 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
José Valim 4bbbb1a230 Clarify docs around codepoints 2020-02-29 23:46:25 +01:00
Wojtek Mach 6f5f4c104e Add guards to Calendar.strftime/3 (#9862)
This improves the error message when we accidentally use the wrong order
of arguments.

Before

    iex(1)> Calendar.strftime("%h", Time.utc_now())
    ** (FunctionClauseError) no function clause matching in Calendar.parse/4

        The following arguments were given to Calendar.parse/4:

            # 1
            ~T[12:26:18.591978]

            # 2
            "%h"

            # 3
            %{
              abbreviated_day_of_week_names: #Function<4.80759775/1 in Calendar.options/1>,
              abbreviated_month_names: #Function<3.80759775/1 in Calendar.options/1>,
              am_pm_names: #Function<0.80759775/1 in Calendar.options/1>,
              day_of_week_names: #Function<2.80759775/1 in Calendar.options/1>,
              month_names: #Function<1.80759775/1 in Calendar.options/1>,
              preferred_date: "%Y-%m-%d",
              preferred_date_invoked: false,
              preferred_datetime: "%Y-%m-%d %H:%M:%S",
              preferred_datetime_invoked: false,
              preferred_time: "%H:%M:%S",
              preferred_time_invoked: false
            }

            # 4
            []

        Attempted function clauses (showing 3 out of 3):

            defp parse("", _datetime, _format_options, acc)
            defp parse(<<"%", rest::binary()>>, datetime, format_options, acc)
            defp parse(<<char, rest::binary()>>, datetime, format_options, acc)

        (elixir 1.11.0-dev) lib/calendar.ex:516: Calendar.parse/4
        (elixir 1.11.0-dev) lib/calendar.ex:507: Calendar.strftime/3

After:

    iex(1)> Calendar.strftime("%h", Time.utc_now())
    ** (FunctionClauseError) no function clause matching in Calendar.strftime/3

        The following arguments were given to Calendar.strftime/3:

            # 1
            "%h"

            # 2
            ~T[12:28:04.638790]

            # 3
            []

        Attempted function clauses (showing 1 out of 1):

            def strftime(date_or_time_or_datetime, string_format, user_options) when is_map(date_or_time_or_datetime) and is_binary(string_format)

        (elixir 1.11.0-dev) lib/calendar.ex:506: Calendar.strftime/3
2020-02-29 13:34:07 +01:00
José Valim 9dd1c3210c Remove unused compilation_status code 2020-02-29 11:46:18 +01:00
José Valim 4894f3b6e0 Pass application tracer warnings to the compiler, closes #9861 2020-02-29 10:38:51 +01:00
José Valim 985ad14121 Handle nil in :profile accordingly 2020-02-29 10:04:37 +01:00
José Valim 12bff7379b Update CHANGELOG 2020-02-29 09:45:02 +01:00
José Valim 8812ca60e2 Use a single option to track profiling data 2020-02-29 09:41:29 +01:00
Calvin Buckley c453603c4c 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 3c5c273c51 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 2ab13725f8 Do not emit duplicate stacktrace warnings 2020-02-28 16:05:34 +01:00
Everett Griffiths 7e5f51164d Clarifies explanation of unicode and Regex character classes, includes example (#9845) 2020-02-27 12:02:14 +01:00
Marcus Kruse 04591c53eb Fix typo in doc for time_zone_periods_from_wall_datetime/2 (#9846) 2020-02-27 09:29:40 +01:00
José Valim 60248a072a Fixes for Erlang/OTP 23 2020-02-26 12:06:08 +01:00
Eric Meadows-Jönsson 475fc714c3 Fix float binary type specifier (#9844) 2020-02-25 20:54:11 +01:00
Wojtek Mach e220ddffa2 Code.fetch_docs/1: Support reading from doc/chunks/*.chunk (#9838) 2020-02-25 09:40:46 +01:00
David Bernheisel 73de8b5ccf Update DateTime.from_unix documentation (#9840)
The documentation stated that negative numbers down to -62167219200 are
supported, but it actually works down to -377705116800. Add doctests to
illustrate the upper and lower boundaries.
2020-02-24 23:16:18 +01:00
José Valim f21f9af667 Rewrite and deprecate System.stacktrace 2020-02-24 21:31:37 +01:00
José Valim f205636bb7 Pass the documentation format to IO.ANSI.print/3 2020-02-24 14:40:03 +01:00
José Valim 3123782d01 Fix the build 2020-02-24 13:04:46 +01:00
José Valim 3018e15bb0 Also use markdown docs formatter when ANSI is disabled 2020-02-24 13:03:50 +01:00
José Valim ebdcfe3dbb Link to tz library too 2020-02-24 09:46:39 +01:00
José Valim 05eb5b2375 Do not show binary types if they are inferred 2020-02-23 10:26:11 +01:00
James Grant 49685f3de7 Fix typo in "Patterns and Guards.md" (#9836) 2020-02-23 01:00:29 +01:00
Johan Mattisson 0b4fcef951 Clarify Map documentation regarding map.key syntax (#9834) 2020-02-22 13:29:18 +01:00
José Valim f2a7ef4e50 Avoid false positives on capture warning 2020-02-20 21:50:47 +01:00
Eric Meadows-Jönsson e98284fbb0 Add checking of patterns in body (#9828) 2020-02-20 16:46:06 +01:00
José Valim aa01bc56b5 Revert "Support import Mod, only: :sigils (#9822)"
It will be moved to the current multi-letter sigils PR.

This reverts commit a6a671e0c7.
2020-02-19 10:42:48 +01:00
José Valim 160d40adb3 Normalize literal functions during expansion 2020-02-18 14:46:45 +01:00
José Valim 843d433f33 Clarify inspect docs 2020-02-17 17:21:52 +01:00
Wojtek Mach a6a671e0c7 Support import Mod, only: :sigils (#9822) 2020-02-17 16:58:09 +01:00
Wojtek Mach d60c202c89 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
Wojtek Mach ee9169f557 Do not compile erlang files with warnings_as_errors unless on CI (#9821) 2020-02-16 16:23:06 +01:00
Bram Verburg 07ac325265 Clarify System.cmd/2 environment handling (#9820) 2020-02-16 10:17:15 +01:00
José Valim 53aac25d92 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 058d5bf514.
2020-02-15 22:02:40 +01:00
Gianluca Nitti a9348a23d4 Use acc type alias in spec of Enum.reduce/3 (#9817) 2020-02-14 17:43:53 +01:00
José Valim 97610c0c06 Fix bootstrap 2020-02-13 12:16:05 +01:00
José Valim e19b2bd2ba Only escape contents outside of interpolation, closes #9812 2020-02-12 20:51:51 +01:00
José Valim d184045d66 Do not crash on fake down messages on stream monitor, closes #9803 2020-02-12 18:31:17 +01:00
José Valim 40fb9adfe7 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 0494f2f149 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