Commit Graph
7878 Commits
Author SHA1 Message Date
eksperimental 9950587f19 Add List.improper?/1 2018-12-08 10:13:39 +01:00
José Valim 0cc21e36b2 Check for function arity in guards for aggregates in Enum (#8487)
In the past, we had decided to not use is_function/1 or
is_function/2 in guards in Enum because the underlying
BadFunctionError was clearer than a FunctionClauseError.
However, today this is no longer necessarily true, due
to exception blaming that is capable of diffing the clauses
in a FunctionClauseError.

Furthermore, not checking for the argument can be an issue
on arguments that are rarely invoked, such as the empty
clause default function passed to Enum.min/2 friends, which
makes some mistakes impossible to catch. For example, someone
may write:

    Enum.min(non_empty_list, &elem(&1, 1))

The user intent here was actually to call `Enum.min_by/2`,
but without the guard, everything appears to work and the
error can go undetected.

Therefore this commit adds function guards to the min and
max aggregate functions in order to provide more feedback.
Depending on how this goes, we can add more guards to the
remaining functions in the future.
2018-12-08 10:12:59 +01:00
Xavier Noria 80e0a95f8f Compare String.next_codepoint/1 with binary pattern matching (#8482) 2018-12-08 08:45:49 +01:00
Eksperimental ec61cdbf0b Replace calls to :lists module in files outside lib/elixir (#8467) 2018-12-08 08:30:44 +01:00
Wojtek Mach f905d98a3f Don't trigger ExDoc warnings on compatibility-and-deprecations page (#8483) 2018-12-07 14:35:48 +01:00
Wojtek Mach ddac6057c6 Update docs (#8479) 2018-12-06 18:19:06 +01:00
Xavier Noria 23259a2f1e Add Range.disjoint?/2 (#8458) 2018-12-06 13:50:49 +01:00
Xavier Noria aa111f806d Cover degenerate case in the description of ranges (#8473)
[ci skip]
2018-12-06 11:45:43 +01:00
Fernando Tapia Rico dde98ccd86 Correct return types for c:Calendar.day_of_era/3 (#8474) 2018-12-06 11:37:21 +01:00
Eksperimental 39ed9a3ae0 Update docs in List.keystore/4 & keyreplace/4 mentioning new_tuple (#8470) 2018-12-06 09:10:57 +01:00
Wojtek Mach fad027f029 Add missing @doc since: "1.8.0" to new functions (#8466) 2018-12-05 17:07:40 +01:00
Xavier Noria 2b55113978 Improve the documentation of Range (#8464)
[ci skip]
2018-12-05 11:47:53 +01:00
José Valim b8a09a5c4d Add week_of_year/3 (#8460) 2018-12-04 23:18:50 +01:00
Kip Cole edd2c6f780 Add Calendar callbacks and Calendar.ISO implementations
* day_of_year/3
  * quarter_of_year/3
  * year_of_era/1
  * day_of_era/3

Signed-off-by: José Valim <jose.valim@plataformatec.com.br>
2018-12-04 12:28:58 +01:00
Lau Taarnskov ca003415f2 Make sure DateTime.truncate returns DateTime when passed map (#8448)
With tests for Calendar.datetime maps being passed to DateTime functions.
2018-12-02 19:28:54 +01:00
Lau Taarnskov f83fb2e7e3 Add Calendar.datetime type and allow it in DateTime functions (#8444)
Instead of requiring a DateTime struct, allow a map containing at least
those fields. In the same way Calendar.naive_datetime is used in
NaiveDateTime (and Calendar.time/Time, Calendar.date/Date).
2018-12-01 11:59:40 -06:00
Xavier Noria 1c502f9f4d Improve documentation of Enum.reduce_while/3 (#8446) 2018-12-01 16:05:53 +01:00
Devon Estes becd5d3aab Change type to link to Elixir docs (#8436)
Since we have an Elixir type for `Supervisor.child_spec()`, it's better
to link to that instead of the Erlang type docs.
2018-11-29 16:16:24 +01:00
José Valim b14dee3d6e Remove outdated comment in NaiveDateTime 2018-11-28 15:10:29 +01:00
Björn Gustavsson 122dcbe90c Eliminate warning for an unused variable (#8431)
Fix a warning that has started to occur because of a recent bug fix in
Erlang/OTP (using fun M:F/A could suppress warnings for unused
variables).
2018-11-27 14:13:42 +01:00
Hans db9314374d Add special fn case to signature_to_binary (#8429) 2018-11-27 01:04:00 +01:00
Eksperimental 29d775dfa7 Fix link to fn/1 special form in Kernel docs (#8427) 2018-11-26 14:05:35 +01:00
José Valim 718263f823 Raise when passing invalid compiler flags to Elixir, closes #7839 2018-11-26 10:09:58 +01:00
Adam Rutkowski 456aae7b63 Update Supervisor calls in Registry docs (#8423) 2018-11-26 09:45:20 +01:00
Adam Rutkowski 515e98fc8b Update supervised Task docs (#8422) 2018-11-26 09:37:58 +01:00
José Valim 741ff046b7 Preserve user's choice on operators, closes #8417 2018-11-25 23:01:53 +01:00
José Valim 690bc55f31 Consistently use eol? in the formatter 2018-11-25 23:01:53 +01:00
yunsong d5294657c4 Remove unnecessary try block in GenServer.reply (#8420) 2018-11-25 09:58:52 +01:00
Thiago Santos 94ae99a811 Update File.Stat typespec (#8418) 2018-11-24 10:09:45 +01:00
Lars Wikman 8e08b3c16e Add missing spaces in error message (#8412) 2018-11-21 10:59:23 +01:00
Kim Shrier f75b3dc846 improve String moduledoc discussion about splitting a string with a pattern (#8411) 2018-11-21 09:22:38 +01:00
Fernando Tapia Rico a725b39c72 Improve error message on DateTime.add/4 (#8410) 2018-11-20 18:45:08 +01:00
José Valim 918c7cea5d Improve syntax on DateTime 2018-11-20 18:02:57 +01:00
José Valim 0fe1964898 Do not use same name twice 2018-11-20 17:55:17 +01:00
Michał Muskała e89e9d874b Compile charlist interpolation more efficiently
Today charlist interpolation is quivalent to calling `String.to_charlist`
on the equivalent string interpolation. It can be more efficient by
leveraging chardata support in the `:unicode` module and encoding as a
list of literal binaries and results of `Kernel.to_string` calls for the
interpolated segments.
2018-11-20 17:54:13 +01:00
Michał Muskała d993efe4bd Add List.to_charlist 2018-11-20 17:54:13 +01:00
Michał Muskała 5c45c222a8 Always inspect MapSet content as regular lists (#8409) 2018-11-20 17:53:42 +01:00
Lau Taarnskov 83c0075201 Add DateTime.add function (#8402) 2018-11-20 17:47:43 +01:00
Devon Estes 32920f5d2e Improve error message for BadFunctionError (#8408)
This way if the term is a function that couldn't be found because it's
referencing an anonymous function from a previous version of a given
module, it says as much instead of saying it expected a function.
2018-11-20 17:42:00 +01:00
Jens Fischer 63fabc44b5 Mention Erlang/OTP 21 no longer blocks on GenServer.cast/2 doc (#8407) 2018-11-20 11:00:51 +01:00
Fernando Tapia Rico e3ec5c3c36 Use proper calendar types (#8403) 2018-11-18 19:53:07 +01:00
Fernando Tapia Rico bfb27257e7 Use "time zone" instead of "timezone" (#8404)
[ci skip]
2018-11-18 19:09:12 +01:00
Fernando Tapia Rico d58340d7ab Omit parens on calls with only do/end blocks (Macro.to_string) (#8396) 2018-11-16 20:51:14 +01:00
Eksperimental 3a3d68385e Revise use of "flag" terminology (#8347) 2018-11-16 09:53:53 +01:00
Lau Taarnskov aef81d1aad Allow DateTime structs to be passed to DateTime.from_naive in typespecs (#8387)
Allow DateTime structs to be passed to DateTime.from_naive in typespecs
Add example in docs for how to use it.
2018-11-15 09:50:40 +01:00
Derek Schneider 7f4756d401 Update Kernel.sigil_D, sigil_T, and sigil_N macro argument names (#8388) 2018-11-14 23:11:46 +01:00
José Valim 6c132b9078 Split calendar_test apart, remove support files from fixtures 2018-11-14 21:35:58 +01:00
José Valim 08b807f7e2 Better document when -> can be used, closes #8386 2018-11-14 18:37:50 +01:00
Lee Marlow 725a36f14d documentation typo fix: Calendar.put_time_zone_database/1 (#8385) 2018-11-13 23:22:00 +01:00
José Valim 6c2dfed036 Add Macro.struct!/2 and use it where reasonable 2018-11-13 20:03:31 +01:00