Skip to content

Fix Date.range/3 raises wrong exception for invalid step - #15690

Merged
josevalim merged 2 commits into
elixir-lang:mainfrom
AlexGx:ag-date_range_arg_ex-fix
Jul 28, 2026
Merged

Fix Date.range/3 raises wrong exception for invalid step#15690
josevalim merged 2 commits into
elixir-lang:mainfrom
AlexGx:ag-date_range_arg_ex-fix

Conversation

@AlexGx

@AlexGx AlexGx commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Fixes Date.range/3 raises wrong exception for non-printable (does not implements String.Chars protocol) step

Current

iex> Date.range(~D[2001-01-01], ~D[2002-01-01], {1})
** (Protocol.UndefinedError) protocol String.Chars not implemented for Tuple

Got value:

    {1}
...

Expected

** (ArgumentError) both dates must have matching calendar and the step must be a non-zero integer, got: ~D[2001-01-01], ~D[2002-01-01], {1}

Comment thread lib/elixir/test/elixir/calendar/date_range_test.exs Outdated
@josevalim
josevalim merged commit 2d0e5ba into elixir-lang:main Jul 28, 2026
15 checks passed
@josevalim

Copy link
Copy Markdown
Member

💚 💙 💜 💛 ❤️

@AlexGx
AlexGx deleted the ag-date_range_arg_ex-fix branch July 28, 2026 20:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants