Skip to content

Commit

Permalink
Fix remote-control-car to accept attribute as default function argume…
Browse files Browse the repository at this point in the history
…nt (#404)
  • Loading branch information
sanderploegsma authored Oct 19, 2023
1 parent baf2d20 commit 740ac09
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/elixir_analyzer/test_suite/remote_control_car.ex
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ defmodule ElixirAnalyzer.TestSuite.RemoteControlCar do

# function header
form do
def new(_ignore \\ "none")
def new(_ignore \\ _ignore)
end

# function without a guard and with a do block
form do
def new(_ignore \\ "none") do
def new(_ignore \\ _ignore) do
_ignore
end
end

# function with do block
form do
def new(_ignore \\ "none") when _ignore do
def new(_ignore \\ _ignore) when _ignore do
_ignore
end
end
Expand Down
7 changes: 7 additions & 0 deletions test/elixir_analyzer/test_suite/remote_control_car_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ defmodule ElixirAnalyzer.TestSuite.RemoteControlCarTest do
def new(nickname \\ "none") when is_binary(nickname) do
%RemoteControlCar{nickname: nickname}
end
end,
defmodule RemoteControlCar do
@default_nickname "none"

def new(nickname \\ @default_nickname) do
%RemoteControlCar{nickname: nickname}
end
end
]
end
Expand Down

0 comments on commit 740ac09

Please sign in to comment.