Skip to content

Commit 9375656

Browse files
committed
Correct ++ pattern matching implementation. Temp fix for travis CI build
1 parent d8bd1d6 commit 9375656

5 files changed

Lines changed: 19 additions & 20 deletions

File tree

.travis.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
sudo: false
2-
language: elixir
3-
elixir:
4-
- 1.4.2
2+
language: erlang
3+
#language: elixir
4+
#elixir:
5+
# - 1.5.0
56
otp_release:
6-
- 19.0
7+
- 20.0-rc1
78
env:
89
- TRAVIS_NODE_VERSION="7"
910
install:
1011
- rm -rf ~/.nvm && git clone https://github.com/creationix/nvm.git ~/.nvm && (cd ~/.nvm && git checkout `git describe --abbrev=0 --tags`) && source ~/.nvm/nvm.sh && nvm install $TRAVIS_NODE_VERSION
1112
- npm install -g yarn
1213
- yarn
14+
before_script:
15+
- wget http://s3.hex.pm/builds/elixir/master.zip
16+
- unzip -d elixir master.zip
17+
- export PATH=$(pwd)/elixir/bin:${PATH}
1318
script:
1419
- mix local.hex --force
1520
- mix local.rebar --force

lib/elixir_script/next/passes/translate/forms/pattern.ex

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ defmodule ElixirScript.Translate.Forms.Pattern do
105105
{ [PM.head_tail(hd(head_patterns), hd(tail_patterns))], params }
106106
end
107107

108+
defp process_pattern({{:., _, [:erlang, :++]}, context, [head, tail]}, state) do
109+
process_pattern({:|, context, [head, tail]}, state)
110+
end
111+
108112
defp process_pattern({:%{}, _, props}, state) do
109113
properties = Enum.map(props, fn({key, value}) ->
110114
{pattern, params} = process_pattern(value, state)
@@ -144,18 +148,6 @@ defmodule ElixirScript.Translate.Forms.Pattern do
144148
{ [PM.bitstring_match(elements)], params }
145149
end
146150

147-
defp process_pattern([{:|, _, [head, tail]}], state) do
148-
{ head_patterns, head_params } = process_pattern(head, state)
149-
{ tail_patterns, tail_params } = process_pattern(tail, state)
150-
params = head_params ++ tail_params
151-
152-
{ [PM.head_tail(hd(head_patterns), hd(tail_patterns))], params }
153-
end
154-
155-
defp process_pattern({{:., _, [:erlang, :++]}, _, [prefix, value]}, state) do
156-
{ [PM.starts_with(prefix)], [Form.compile!(value, state)] }
157-
end
158-
159151
defp process_pattern({:<>, _, [prefix, value]}, state) do
160152
{ [PM.starts_with(prefix)], [Form.compile!(value, state)] }
161153
end

lib/elixir_script/translator/state.ex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ defmodule ElixirScript.Translator.State do
3030
rescue
3131
FunctionClauseError ->
3232
acc
33+
ArgumentError ->
34+
acc
3335
end
3436
end)
3537
end

test/cli_test.exs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
defmodule ElixirScript.CLI.Test do
22
use ExUnit.Case
33

4-
test "parse_args -e expands to elixir" do
5-
{_, args} = ElixirScript.CLI.parse_args(["1 + 1", "-e"])
6-
assert args == [elixir: true]
4+
test "parse_args -js-module includes js module" do
5+
{_, args} = ElixirScript.CLI.parse_args(["Example", "--js-module", "React:react"])
6+
assert args == [js_module: "React:react"]
77
end
88
end

test/next/passes/translate/forms/remote_test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ defmodule ElixirScript.Translate.Forms.Remote.Test do
88
state = %{function: {:each, nil}, module: Enum, vars: %{:_ => 0, "entry" => 0, "enumerable" => 0, "fun" => 0}}
99

1010
{js_ast, _} = Remote.compile(ast, state)
11-
assert js_ast == J.identifier("fun")
11+
assert js_ast == J.identifier("fun0")
1212
end
1313

1414
end

0 commit comments

Comments
 (0)