Commit Graph
3446 Commits
Author SHA1 Message Date
Eksperimental 84f9128825 Replace use of "item(s)" with "element(s)" in Enum module (#8885) 2019-03-12 23:24:22 +01:00
Fernando Tapia Rico 0903ad17bc Ensure inspect returns valid ~r// expressions (#8872)
Inspecting regular expressions that contain backslashes (\)
followed by slashes (/) result in invalid ~r// expressions:

    iex(1)> Regex.compile("a\\/b")
    {:ok, ~r/a\\/b/}
    iex(2)> Regex.match?(~r/a\\/b/, "a/b")
    ** (SyntaxError) iex:2: syntax error before: ','
2019-03-11 13:57:43 +01:00
Fernando Tapia Rico b88cd49d8d Validate __struct__ key in map returned by __struct__/0,1 (#8864) 2019-03-07 12:12:30 +01:00
Eksperimental 23b2a09079 Improve error message on invalid @doc (#8852) 2019-03-03 18:22:15 -08:00
SpaceEEC 33d484231b Ensure :name is given in Registry.start_link/1 (#8850) 2019-03-03 17:07:01 -08:00
Andrea Leopardi 3680e85355 Add System.fetch_env/1 and System.fetch_env!/1 (#8846)
This commit adds the System.fetch_env/1 and System.fetch_env!/1 
functions as per the discussion in 
https://groups.google.com/forum/#!topic/elixir-lang-core/QGxEibK4y7Q.

I chose to keep using the same underlying implementation for fetch_env/1 
as the one for get_env/1 because the number of lines would have been the 
same but we would have added one function call.
2019-03-01 12:32:31 -08:00
Carlo Colombo fc039770b4 Enable Access.at/1 to handle negative index (#8843)
Enabling negative index as Enum.at/2 to keep it consistent.
2019-03-01 10:03:10 -08:00
Andrea Leopardi 12953fe8da Remove StreamData-related stuff from the formatter configuration (#8833)
We're not including StreamData (https://github.com/whatyouhide/stream_data) in the standard library anymore. It doesn't make sense that we have StreamData functions in the default locals without parens of the formatter. Instead, we solve the problem on the StreamData side with https://github.com/whatyouhide/stream_data/pull/124.
2019-02-28 23:34:39 +01:00
Fernando Tapia Rico 0a81b27861 Raise if a macro is invoked before its definition (#8822) 2019-02-25 22:48:21 +01:00
Wojtek Mach b819b9f093 Add ~U sigil for UTC date times (#8824) 2019-02-25 15:01:12 +01:00
Wojtek Mach ff25707c73 Set DateTime.from_unix precision to microseconds for units not divisible by 10 (#8823)
Before:

    DateTime.from_unix!(143_256_036_886_856, 1024).microsecond
    {320312, 3}

After:

    DateTime.from_unix!(143_256_036_886_856, 1024).microsecond
    {320312, 6}
2019-02-24 16:04:43 +01:00
Fernando Tapia Rico 34e0fcd923 Do not allow to override macros as functions (#8816)
And vice-versa.

Overriding a macro as a function (and vice-versa) might produce
undesired effects.

For example, it's not clear if the following code should or
should not raise:

    defmodule Foo do
      def foo, do: bar()
      defmacro bar, do: :ok
      defoverridable bar: 0
      def bar, do: :ok
    end

On top of that, `super` does not currently work for such cases.
2019-02-23 09:08:16 +01:00
Adam Zapaśnik 74cbc8f0ea Raise error when doc attribute is true (#8814) 2019-02-21 12:39:28 +01:00
Fernando Tapia Rico 6595283c35 Improve defoverridable test suite (#8802) 2019-02-18 07:15:22 +01:00
Rauan Assis 4dda125e78 Adding missing List functions tests (#8804) 2019-02-18 07:14:23 +01:00
Aaron Renner a190c58680 Allow integer time units for DateTime.from_unix!/2 (#8801) 2019-02-15 19:57:04 +01:00
Eksperimental 2622fd6b0a Remove Integer.to_string/1 and Integer.to_charlist/1 (#8777)
They are not needed, since they are covered by their /2 version.
2019-02-07 09:29:10 +01:00
Eksperimental 99d919e0c8 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
José Valim 5e2087cbb8 Take into account spawned processes when checking for deadlocks
Elixir v1.6 introduced Kernel.ParallelCompiler.async/1, which
allows a file to spawn other processes to speed up compilation.
However, the compiler implementation assumed that if the number
of waiting processes were equal to the number of queued files,
it was a deadlock. However, with the introduction of async,
this is not necessarily true, as the async entries can be waiting
too. So this commit changes the compiler to track all spawned
entries.

Closes #8744.
2019-01-31 13:24:38 +01:00
Wojtek Mach a87d39ed05 Include field names in generated type for records (#8742)
For this module:

    defmodule M do
      import Record
      @type t :: record(:r, foo: atom(), bar: integer())
      defrecord :r, [:foo, :bar]
    end

`@type t` is defined as the following:

Before this patch:

    @type t() :: {:r, atom(), integer()}

After this patch:

    @type t() :: {:r, foo :: atom(), bar :: integer()}

This is similar to loading record definition in Erlang shell:

    1> rr(file).
    [file_descriptor,file_info]
    2> rl(file_descriptor).
    -record(file_descriptor,{module :: module(),data :: term()}).
    ok
2019-01-30 19:42:39 +01:00
José Valim 92f048f7cf Avoid races on windows on timer test
We check for >= 5000 (us) instead of >= 10000 (us)
because the resolution on Windows system is not high
enough and we would get a difference of 9000 from
time to time. So a value halfway is good enough.
2019-01-29 23:30:24 +01:00
Fernando Tapia Rico 25c61e39b4 Use default args in Calendar.ISO.*_to_string/* (#8707) 2019-01-26 09:21:34 +01:00
José Valim 0ccf798fc2 Fix rounding for subnormal floats (#8687)
Closes #8685
2019-01-25 08:39:41 +01:00
Eksperimental 5bd907d126 Use hexadecimal notation in code points in tokenizer error msg (#8669) 2019-01-22 13:39:40 +01:00
Eksperimental 3beaf09dfe Correct arity in List test (#8670) 2019-01-22 08:58:37 +01:00
Eksperimental e81f8c065c Simplify guards in List.ascii_printable?/2 (#8656) 2019-01-22 08:50:48 +01:00
Wojtek Mach 736a1ac906 Update Module.spec_to_callback to keep existing specs and copy docs (#8663) 2019-01-21 19:49:44 +01:00
Eksperimental f1eca78ca4 Improve docs in Module functions and raise errors (#8635) 2019-01-21 18:12:51 +01:00
Eksperimental 6fceb8caaa Add test to List.ascii_printable?/2 (#8655)
Add test that checks improper lists with limit
2019-01-20 19:23:09 +01:00
Roman Smirnov 4bdc4e4050 Fix parsing Markdown links for h function (fix #8629) (#8641) 2019-01-16 22:39:14 +01:00
Eksperimental 0da99435c3 Use ID and not id (#8639)
The command used to detect these entries:
ag -s "\b(?<![/:{_\[.])ids?(?![}:_\]])(?!\(\))(?!enti)(?!ea)(?!iom)(?!x)"  --elixir
2019-01-16 19:14:39 +01:00
José Valim a6e9de56db Allow __MODULE__.Something in a nested defmodule
Defining __MODULE__.Something in a nested defmodule would fail
to compile. This commit address this:

    defmodule Foo do
      defmodule __MODULE__.Bar do
        __MODULE__ == Elixir.Foo.Bar
      end
    end

Since `__MODULE__` expands to a fully qualified name `Elixir.Foo`,
the nested module must then be `Elixir.Foo.Bar`. This commit also
fixes an alias leakage that would happen under such scenarios.

Another possible interpretation would be for it to return `Foo.Foo.Bar`.
However, that would mean we would not be able to access the module
right below its definition using `__MODULE__.Bar`, which means its
`Foo.Foo.Bar` would be the incorrect choice.
2019-01-14 23:58:37 +01:00
José Valim 085cb22352 Only perform behaviour checking if blaming 2019-01-13 13:29:52 +01:00
José Valim d7d49e1f58 Consistently forbid upcasting in calendar conversion functions 2019-01-12 09:47:55 +01:00
Bryan Paxton 61a12f4a53 Improve coverage of Version.Parser (#8607)
Added assertions to exists test to cover lines 409, 412, and 511
2019-01-09 13:13:44 +01:00
José Valim 427c2aa3ec Revamp Elixir CLI (#8595)
This commit adds 6 new options to elixir CLI to aid releases:

  * `--pipe-to PIPEDIR LOGDIR` - invokes run_erl with daemon pipe and logs (only on Unix-like systems)

  * `--rpc-eval NODE COMMAND` - evaluates the given expression on the given node

  * `--boot FILE`, `--boot-var VAR VALUE`, `--erl-config FILE` and `--vm-args FILE` - which are equivalent to Erlang's `-boot`, `-boot_var`, `-config` and `-args_file`

We have also rewritten the CLI to only pass Elixir options to Kernel.CLI.
2019-01-08 20:44:43 +01:00
Petr Stepchenko 01fd5a53f3 Add File.rename!/2 (#8606) 2019-01-08 20:25:03 +01:00
José Valim 3e673ac134 Ensure we support counters in bitstring size vars 2019-01-07 22:31:31 +01:00
Fernando Tapia Rico b2c698d295 Provide better errors with invalid dates in Calendar.ISO (#8601) 2019-01-07 21:58:31 +01:00
Fernando Tapia Rico 144e0427c7 Handle non-printable args in StringIO gracefully (#8600)
Non-printable arguments were killing the StringIO process, which
was killing the Logger handler associated to it. That was
causing some errors when users were running their test suites
with `capture_log: true`, because the proxy (Logger handler) was
not there when ExUnit.CaptureLog was trying to remove it.
2019-01-06 21:02:49 +01:00
Fernando Tapia Rico 7ad213b289 Error on undefined variables in bitstring segments (#8598)
Binary/bitstring matching allows to dynamically define the
`size` of the binary in certain conditions:

  * if the `size` variable is defined prior to the pattern
    match:

        iex> size = 8
        iex> <<a::size(size), rest::binary>> = "hello"
        iex> a
        104

  * if the `size` variable is matched within the same
    binary/bitstring match, prior to its use:

        iex> <<name_size::size(8), name::binary-size(name_size), _rest::binary>> = <<5, "Frank the Walrus">>
        iex> name
        "Frank"

Other cases are considered illegal patterns, for example:

    {name_size, <<name::binary-size(name_size), _rest::binary>>} = {5, "Frank the Walrus"}

This commit raises a `CompileError: undefined variable ...` for such cases.
2019-01-05 17:46:33 +01:00
José Valim a356e60d45 Refactor Kernel.CLI tests and fix faulty assertions 2019-01-05 13:18:28 +01:00
José Valim 9a87eb5f98 Add System.restart/0 and System.pid/0 (#8597) 2019-01-05 13:17:59 +01:00
José Valim 091886d176 Handle unquote in remote call, closes #8588 2019-01-05 09:17:23 +01:00
Wojtek Mach ca40d1594c Show docs for callback with multiple clauses (#8553)
* Merge callback's multiple clauses in elixir_erl.erl
* Simpler callbacks deduplication
2019-01-02 13:12:01 +01:00
Bruce Park 8aeeb86dfe Improve Protocol.UndefinedError message... (#8579)
when passing the module name of a struct

Addresses https://github.com/elixir-lang/elixir/issues/8532
2019-01-02 13:08:37 +01:00
José Valim b5f6e8e4b2 Default to required map keys
This aligns the behaviour with atoms keys and maps
for state without forcing everyone to pick one or
the other.

For clarity, developers can always use required/optional.
2018-12-27 17:14:21 +01:00
nico piderman a15b07a283 User defined types with the name record fail to compile in 1.8.0-rc.0 (#8569)
Closes https://github.com/elixir-lang/elixir/issues/8564

This is my first attempt to contribute code to elixir, so please forgive me if this PR is completely naive.

Besides adding the `is_list/1` guards, I have updated the error message to specify that record specifications must use an atom `literal` as the name, to make it clear that the type `atom` is also not valid.
2018-12-27 17:06:13 +01:00
José Valim ad4a363232 Swap argument order to avoid failures on OTP master 2018-12-22 10:04:28 +01:00
José Valim 0c1df34645 Standardize more TODOs 2018-12-21 13:42:54 +01:00