Skip to content

Commit 3938cc9

Browse files
committed
Update list concat translation to not wrap extra list
1 parent 439208e commit 3938cc9

File tree

6 files changed

+2582
-12
lines changed

6 files changed

+2582
-12
lines changed

lib/elixir_script/passes/translate/form.ex

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,18 @@ defmodule ElixirScript.Translate.Form do
2222
{ J.literal(form), state }
2323
end
2424

25+
def compile([{:|, _, [head, tail]}], state) do
26+
ast = J.call_expression(
27+
J.member_expression(
28+
J.array_expression([compile!(head, state)]),
29+
J.identifier("concat")
30+
),
31+
[compile!(tail, state)]
32+
)
33+
34+
{ ast, state }
35+
end
36+
2537
def compile({:|, _, [head, tail]}, state) do
2638
ast = J.call_expression(
2739
J.member_expression(

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"license": "MIT",
2424
"dependencies": {
2525
"erlang-types": "^1.0.1",
26-
"tailored": "^2.6.3"
26+
"tailored": "^2.6.4"
2727
},
2828
"devDependencies": {
2929
"ava": "^0.21.0",

priv/build/iife/ElixirScript.Core.js

Lines changed: 2559 additions & 6 deletions
Large diffs are not rendered by default.

src/javascript/lib/core/erlang_compat/io.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import erlang from './erlang';
22

33
function put_chars(ioDevice, charData) {
4-
let dataToWrite = erlang.iolist_to_binary(charData);
4+
const dataToWrite = erlang.iolist_to_binary(charData);
55

66
if (ioDevice === Symbol.for('stderr')) {
77
console.error(dataToWrite);

src/javascript/lib/core/protocol.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class Protocol {
3131
fun = this.registry.get(Core.BitString)[funName];
3232
} else if (
3333
thing &&
34+
thing instanceof Map &&
3435
thing.has(Symbol.for('__struct__')) &&
3536
this.hasImplementation(thing)
3637
) {
@@ -72,7 +73,11 @@ class Protocol {
7273
thing === Core.BitString
7374
) {
7475
return this.registry.has(thing);
75-
} else if (thing && thing.has(Symbol.for('__struct__'))) {
76+
} else if (
77+
thing &&
78+
thing instanceof Map &&
79+
thing.has(Symbol.for('__struct__'))
80+
) {
7681
return this.registry.has(thing.get(Symbol.for('__struct__')).__MODULE__);
7782
}
7883

yarn.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3678,9 +3678,9 @@ table@^4.0.1:
36783678
slice-ansi "0.0.4"
36793679
string-width "^2.0.0"
36803680

3681-
tailored@^2.6.3:
3682-
version "2.6.3"
3683-
resolved "https://registry.yarnpkg.com/tailored/-/tailored-2.6.3.tgz#27d1069dd3f5b2f2009d6437efcb26c595bccfda"
3681+
tailored@^2.6.4:
3682+
version "2.6.4"
3683+
resolved "https://registry.yarnpkg.com/tailored/-/tailored-2.6.4.tgz#c81bdfe8b50c35298ed87c684d493467a87182c5"
36843684
dependencies:
36853685
erlang-types "^1.0.1"
36863686

0 commit comments

Comments
 (0)