Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to Elixir 1.17 #1495

Merged
merged 2 commits into from
Jun 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ name: elixir / main ci

on:
push:
branches: [ main ]
branches: [main]
pull_request:
workflow_dispatch:

Expand All @@ -17,8 +17,8 @@ jobs:
runs-on: ubuntu-20.04
strategy:
matrix:
elixir: [1.16]
otp: [26.2]
elixir: [1.17]
otp: [27.0]

steps:
- name: Checkout code
Expand Down Expand Up @@ -76,8 +76,6 @@ jobs:
strategy:
matrix:
include:
- elixir: '1.11.0'
otp: '23.2'
- elixir: '1.12.0'
otp: '24.0'
- elixir: '1.13.0'
Expand All @@ -88,6 +86,8 @@ jobs:
otp: '26.0'
- elixir: '1.16.0'
otp: '26.2'
- elixir: '1.17.0'
otp: '27.0'

steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

## Setup

The exercises currently target Elixir versions from 1.11 to 1.16 and Erlang/OTP versions from 21 to 26. Detailed installation instructions can be found at
The exercises currently target Elixir versions from 1.12 to 1.17 and Erlang/OTP versions from 24 to 27. Detailed installation instructions can be found at
[https://elixir-lang.org/install.html](https://elixir-lang.org/install.html). We recommend using the [asdf version manager](https://github.com/asdf-vm/asdf) to manage multiple Elixir versions.

## Testing
Expand Down
2 changes: 1 addition & 1 deletion exercises/concept/rpn-calculator/.meta/exemplar.ex
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ defmodule RPNCalculator do
try do
{:ok, operation.(stack)}
rescue
e -> {:error, e.message}
e in ArgumentError -> {:error, e.message}
end
end
end
73 changes: 39 additions & 34 deletions exercises/concept/top-secret/test/top_secret_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -37,41 +37,46 @@ defmodule TopSecretTest do
end
"""

ast = {
:defmodule,
[line: 1],
[
{:__aliases__, [line: 1], [:List]},
[
do: {
:__block__,
[],
[
{:@, [line: 2],
assert {
:defmodule,
[line: 1],
[
{:__aliases__, [line: 1], [:List]},
[
{:spec, [line: 2],
[{:"::", [line: 2], [{:delete, [line: 2], [[], {:any, [line: 2], nil}]}, []]}]}
]},
{:@, [line: 3],
[
{:spec, [line: 3],
[
{:"::", [line: 3],
[
{:delete, [line: 3], [[{:..., [line: 3], nil}], {:any, [line: 3], nil}]},
{:list, [line: 3], nil}
]}
]}
]},
{:def, [line: 4],
[{:delete, [line: 4], [{:list, [line: 4], nil}, {:element, [line: 4], nil}]}]}
]
}
]
]
}

assert TopSecret.to_ast(string) == ast
do: {
:__block__,
[],
[
{:@, [line: 2],
[
{:spec, [line: 2],
[
{:"::", [line: 2],
[{:delete, [line: 2], [[], {:any, [line: 2], nil}]}, []]}
]}
]},
{:@, [line: 3],
[
{:spec, [line: 3],
[
{:"::", [line: 3],
[
{:delete, [line: 3],
[[{:..., [line: 3], _nil_or_empty_list}], {:any, [line: 3], nil}]},
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1.16 gives [{:..., [line: 3], nil}] but 1.17 gives [{:..., [line: 3], []}] so I needed to change the test to accept both versions.

The 1.17 changelog mentions in the debug section

[Kernel] Resolve inconsistencies of how .. and ... are handled at the AST level

So that must be part of it.

Does that need a comment?
There could also be other ways of fixing it, for example quoting ... and shoving it in the expected value.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the current way is the simplest way of resolving the problem

{:list, [line: 3], nil}
]}
]}
]},
{:def, [line: 4],
[
{:delete, [line: 4],
[{:list, [line: 4], nil}, {:element, [line: 4], nil}]}
]}
]
}
]
]
} = TopSecret.to_ast(string)
end
end

Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/atbash-cipher/.meta/example.ex
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
defmodule Atbash do
@key Enum.zip(?a..?z, ?z..?a) |> Enum.into(%{})
@key Enum.zip(?a..?z, ?z..?a//-1) |> Enum.into(%{})

@doc """
Encode a given plaintext to the corresponding ciphertext
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/beer-song/.meta/example.ex
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ defmodule BeerSong do
"#{number} bottles of beer on the wall, #{number} bottles of beer.\nTake one down and pass it around, #{number - 1} bottles of beer on the wall.\n"
end

def lyrics(range \\ 99..0) do
def lyrics(range \\ 99..0//-1) do
range
|> Enum.map(&verse/1)
|> Enum.join("\n")
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/isbn-verifier/.meta/example.ex
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ defmodule IsbnVerifier do
isbn
|> String.replace("-", "")
|> String.graphemes()
|> Enum.zip(10..1)
|> Enum.zip(10..1//-1)
|> Enum.map(&checksum_weighting/1)
|> Enum.sum()

Expand Down
4 changes: 2 additions & 2 deletions exercises/practice/kindergarten-garden/.meta/example.ex
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ defmodule Garden do
letters = "#{first_row_letters}#{second_row_letters}"
map = add_to_map(map, current_name, letters)

first_row = String.slice(first_row, 2..-1)
second_row = String.slice(second_row, 2..-1)
first_row = String.slice(first_row, 2..-1//-1)
second_row = String.slice(second_row, 2..-1//-1)
populate_map(first_row, second_row, map, student_names)
end

Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/pascals-triangle/.meta/example.ex
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ defmodule PascalsTriangle do
defp each_cons(list) do
list
|> Enum.flat_map(&[&1, &1])
|> Enum.slice(1..-2)
|> Enum.slice(1..-2//-1)
|> Enum.chunk_every(2)
end

Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/sgf-parsing/.meta/example.ex
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ defmodule SgfParsing do
with {:ok, result, rest} <- some(parser).(input) do
{:ok, result, rest}
else
{:error, _err, ^input} -> {:ok, [], input}
{:error, _err, rest} when rest == input -> {:ok, [], input}
Copy link
Contributor Author

@jiegillet jiegillet Jun 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one seems like a bug (in Elixir or OTP) to be honest, I'll try to reproduce on something simpler and check.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was fixed in 1.17.1: https://github.com/elixir-lang/elixir/releases/tag/v1.17.1

[Kernel] Fix bug when using pinned variables inside with's else patterns

Since this is just in an example file, I'm fine completely ignoring this issue (meaning: doing the change you're suggesting to the example file and that's it)

err -> err
end
end
Expand Down
Loading