Skip to content

Commit 2a4b9a1

Browse files
committed
Fix merge conflicts
2 parents 848a660 + d461956 commit 2a4b9a1

File tree

4 files changed

+33
-1
lines changed

4 files changed

+33
-1
lines changed

lib/elixir_script/passes/translate/form.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ defmodule ElixirScript.Translate.Form do
335335
{ast, state}
336336
end
337337

338-
def compile({{:., _, [{_, _, atom} = var, func_or_prop]}, _, []}, state) when is_atom(atom) do
338+
def compile({{:., _, [var, func_or_prop]}, _, []}, state) when not is_atom(var) do
339339
ast = Helpers.call(
340340
ElixirScript.Translate.Forms.JS.call_property(),
341341
[compile!(var, state), J.literal(to_string(func_or_prop))]

test/integration/integration_test.exs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,9 @@ defmodule ElixirScript.Integration.Test do
2424
val = call_compiled_function Integration, :map_equals, []
2525
assert val == true
2626
end
27+
28+
test "multi-remote call" do
29+
val = call_compiled_function Integration, :multi_field_call, []
30+
assert val == "5,000,000"
31+
end
2732
end

test/passes/translate/form_test.exs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ defmodule ElixirScript.Translate.Forms.Test do
22
use ExUnit.Case
33
alias ElixirScript.Translate.Form
44
alias ElixirScript.Translate.Identifier
5+
alias ElixirScript.Translate.Helpers
56
alias ESTree.Tools.Builder, as: J
67
require StreamData
78
import PropertyTest
@@ -146,4 +147,25 @@ defmodule ElixirScript.Translate.Forms.Test do
146147
J.literal(3)
147148
])
148149
end
150+
151+
test "calling field on field" do
152+
ast = {{:., [line: 16],
153+
[{{:., [line: 16], [{:map, [line: 16], nil}, :token_count]}, [line: 16],
154+
[]}, :toLocaleString]}, [line: 16], []}
155+
156+
state = %{function: {:something, nil}, vars: %{}}
157+
158+
{js_ast, _} = Form.compile(ast, state)
159+
160+
assert js_ast == Helpers.call(
161+
ElixirScript.Translate.Forms.JS.call_property(),
162+
[
163+
Helpers.call(
164+
ElixirScript.Translate.Forms.JS.call_property(),
165+
[J.identifier("map"), J.literal("token_count")]
166+
),
167+
J.literal("toLocaleString")
168+
]
169+
)
170+
end
149171
end

test/support/integration.ex

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,9 @@ defmodule Integration do
1616
map2 = %{test: "map"}
1717
map1 == map2
1818
end
19+
20+
def multi_field_call do
21+
map = %{token_count: 5000000}
22+
map.token_count.toLocaleString()
23+
end
1924
end

0 commit comments

Comments
 (0)