Commit Graph
3400 Commits
Author SHA1 Message Date
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
Fernando Tapia Rico 450261295f Deprecate %{key => value} in typespecs (#8537)
%{required(foo) => bar} and %{optional(foo) => bar} should be used.
2018-12-21 12:55:57 +01:00
José Valim 2d139352bb Fix cond scope and improve coverage, closes #8542 (#8544) 2018-12-21 12:54:04 +01:00
José Valim 5ce4b61991 Add :reduce to for comprehensions (#8531) 2018-12-21 12:51:28 +01:00
Fernando Tapia Rico da561ca876 Raise compile errors on bad record types
The record name must be an atom.

These checks were previously performed by erl_lint.
2018-12-18 00:21:00 +01:00
Fernando Tapia Rico f702f932a2 Raise compile errors on bad binary types
Both size and unit must be non-negative integers.

These checks were previously performed by erl_lint.
2018-12-18 00:21:00 +01:00
Fernando Tapia Rico b3f59d9f9c Raise compile errors on bad range types
Both sides of the range must be integers (after expansion), and
the "first" value must be greater than the "last" value.

These checks were previously performed by erl_lint.
2018-12-18 00:21:00 +01:00
José Valim 24ff3df592 Remove week_of_year
We are uncertain this is the best API to expose this
information. Maybe it is best to expose this as a separate
calendar. That uses the week-based year and week-based
month in the Date/Time structs.
2018-12-17 10:21:35 +01:00
Dennis Beatty f244ee310f add hint for behaviours on UndefinedFunctionErrors (#8517)
This is the first pass on #8513. I would love any feedback you have on this.
2018-12-14 17:21:27 +01:00
José Valim 55ead12b0a Move record warning to warning test file 2018-12-11 19:50:22 +01:00
José Valim 95934e56c4 Add $callers tracking to Task (#8510)
This allows us to track which process invoked the Task
besides its ancestors in the supervision tree.

Closes #7995
2018-12-11 19:05:53 +01:00
Michał Muskała f7935d9351 Make sure records use the dsetelement optimisation (#8062)
Closes #8059

Additionally some more refactorings of the Record module
2018-12-11 12:44:02 +01:00
Eksperimental d5c5e7eb5f Revamp List.ascii_printable?/2 (#8491)
- Simplify logic
- Add specs
- Validate specs with guards, raising on non-lists
- Add tests
- Correct documentation about improper lists
- Rename argument `counter` to `limit`
2018-12-11 11:53:15 +01:00
José Valim 499446737e Allow posix time on touch and document proper defaults
This fixes issue #8450 which was caused by the user of
`system_time` when `os_time` should have been used.

This commit improves the touch API by also allowing
posix times in `File.touch/2` and also document its
defaults. With this change, we phase out the remaining
use of Erlang's `:calendar` module in Elixir.
2018-12-11 10:31:37 +01:00
Eksperimental ca1bc6c3da IO.ANSI.Docs: Make regex in escape_underlines_in_link/1 handle all schemes (#8497)
It follows the same rules as URI.parse/1

Related to #8494
2018-12-10 09:48:37 +01:00
Eksperimental f2d1b4209b ascii -> ASCII (#8499) 2018-12-10 09:24:34 +01:00
HUANG Wei a6139bc2c0 Stricter link check in IO.ANSI.Docs module (#8494)
Closes #8449
2018-12-09 18:06:25 +01:00
eksperimental 9950587f19 Add List.improper?/1 2018-12-08 10:13:39 +01:00
Eksperimental ec61cdbf0b Replace calls to :lists module in files outside lib/elixir (#8467) 2018-12-08 08:30:44 +01:00
Xavier Noria 23259a2f1e Add Range.disjoint?/2 (#8458) 2018-12-06 13:50:49 +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
Hans db9314374d Add special fn case to signature_to_binary (#8429) 2018-11-27 01:04:00 +01:00
José Valim 741ff046b7 Preserve user's choice on operators, closes #8417 2018-11-25 23:01:53 +01:00
José Valim 0fe1964898 Do not use same name twice 2018-11-20 17:55:17 +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
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
José Valim 6c132b9078 Split calendar_test apart, remove support files from fixtures 2018-11-14 21:35:58 +01:00
José Valim 6c2dfed036 Add Macro.struct!/2 and use it where reasonable 2018-11-13 20:03:31 +01:00
José Valim 774a9baa93 Resolve circular struct dependencies in typespecs (#8377)
Prior to this patch, if a module depends on the struct of
another module and that other module depends on the struct
of the first module inside typespecs, it would lead to a
compiler deadlock, which this deadlock would not happen
in "regular code".

This commit also adds a test to ensure @enforce_keys are
not enforced when expanding typespecs.

For now, we are using a compiler private API, but we should
provide a public version for it in a future commit.
2018-11-13 17:47:24 +01:00
Lau Taarnskov b8b1a4ba8a Add TimeZoneDatabase behaviour for time zone data.
Signed-off-by: José Valim <jose.valim@plataformatec.com.br>
2018-11-13 17:43:59 +01:00
José Valim b8e71290d3 Ignore escape characters inside markdown backticks (#8384) 2018-11-12 13:14:55 +01:00
Wojtek Mach 616263f9de Expand operands in size*unit bitstring modifier (#8375) 2018-11-08 19:42:55 +01:00
José Valim ac24df8625 Handle years more than 9999 when printing, closes #8368 2018-11-06 16:05:35 +01:00
José Valim 9610b2bd46 Support subnormal floats in Float.ratio/1 (#8360) 2018-11-06 09:51:20 +01:00
Sun Yaozhu 1967a06abe Fix ZWJ handling in Unicode grapheme clusters (#8361) 2018-11-04 19:56:36 +01:00
Eric Meadows-Jönsson d14f04c950 Change else clause error to warning (#8351) 2018-10-29 21:09:52 +01:00
Fernando Tapia Rico d24ff660cd Avoid errors with more than one duplicated key (#8346)
Closes #8345
2018-10-26 17:44:09 +02:00
Fernando Tapia Rico 687c50c42a Deprecate System.cwd/0 and System.cwd!/0 (#8344) 2018-10-26 09:21:43 +02:00
Mitchell Hanberg 749d89139c Improve error message for invalid quoted expression (#8336) 2018-10-25 19:37:04 +02:00
José Valim f01de95cb2 Raise when piping into unquote, closes #8331 2018-10-25 10:01:10 +02:00
Fernando Tapia Rico 6c4d359b1a Add missing space in error message (#8328) 2018-10-24 15:19:50 +02:00
Eksperimental 74f864dd3c Improvements to the Version module documentation (#8313)
- General improvements to docs
- Minor grammar corrections
- Add doc test examples to Version.match?/3 using :allow_pre option
- List all the operators allowed in requirements.
- Mention that the PATH part of the version can be used as operand with ~>
- Make a clarification that "`~>` will never include pre-release versions of its upper bound,
  regardless of the usage of the `allow_pre:` option", and add tests to verify this
- The requirement table has been update:
  - It doesn't use the consecutive PATCH number in the example, so `~> 2.1.2` will not use
    `2.1.3-dev` but `2.1.6-dev` to make it that the upper bound is within the MINOR part
    not the PATCH one
  - Remove "-" and replace with "`true` or `false`" as it is not clear what "-" means in that example,
   and it could be understood that the option is not allowed in that example.
  - Updated to "`true` or `false`" the cases whether both options return the same value.
  - Added an additional example: `>= 2.1.0` | `2.2.0-dev` | `true` | `true`
2018-10-22 21:42:36 +02:00
Eksperimental bd9ac87d07 Update use of numbers as adjectives (#8309)
- Replace "two element tuples" with "two-element tuples" for every number in 1..10
- Replace "2-element tuples" with "two-element tuples" for every number
- "1-based" with "one-based"
- "0-based" with "zero-based"
2018-10-21 00:03:38 +02:00