Skip to content

Commit 7605b2d

Browse files
committed
wrap generated with code in do block again
1 parent f3c7b11 commit 7605b2d

File tree

6 files changed

+23
-4
lines changed

6 files changed

+23
-4
lines changed

moonscript/compile/line.lua

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,5 +292,12 @@ line_compile = {
292292
end,
293293
group = function(self, node)
294294
return self:stms(node[2])
295+
end,
296+
["do"] = function(self, node)
297+
do
298+
local _with_0 = self:block()
299+
_with_0:stms(node[2])
300+
return _with_0
301+
end
295302
end
296303
}

moonscript/compile/line.moon

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,3 +163,7 @@ line_compile =
163163
group: (node) =>
164164
@stms node[2]
165165

166+
do: (node) =>
167+
with @block!
168+
\stms node[2]
169+

moonscript/transform.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ Statement = Transformer({
266266
with = function(node, ret)
267267
local _, exp, block = unpack(node)
268268
local scope_name = NameProxy("with")
269-
return build.group({
269+
return build["do"]({
270270
build.assign_one(scope_name, exp),
271271
Run(function(self)
272272
return self:set("scope_var", scope_name)
@@ -692,7 +692,7 @@ Value = Transformer({
692692
table.remove(node, #node)
693693
local base_name = NameProxy("base")
694694
local fn_name = NameProxy("fn")
695-
return value(build.block_exp({
695+
return Value(build.block_exp({
696696
build.assign({
697697
names = {
698698
base_name

moonscript/transform.moon

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ Statement = Transformer {
159159
with: (node, ret) ->
160160
_, exp, block = unpack node
161161
scope_name = NameProxy "with"
162-
build.group {
162+
build["do"] {
163163
build.assign_one scope_name, exp
164164
Run => @set "scope_var", scope_name
165165
build.group block
@@ -406,7 +406,7 @@ Value = Transformer {
406406
base_name = NameProxy "base"
407407
fn_name = NameProxy "fn"
408408

409-
value build.block_exp {
409+
Value build.block_exp {
410410
build.assign {
411411
names: {base_name}
412412
values: {node}

moonscript/types.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,12 @@ build = setmetatable({
146146
body
147147
}
148148
end,
149+
["do"] = function(body)
150+
return {
151+
"do",
152+
body
153+
}
154+
end,
149155
assign_one = function(name, value)
150156
return build.assign({
151157
names = {

moonscript/types.moon

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ build = nil
8383
build = setmetatable {
8484
group: (body) ->
8585
{"group", body}
86+
do: (body) ->
87+
{"do", body}
8688
assign_one: (name, value) ->
8789
build.assign {
8890
names: {name}

0 commit comments

Comments
 (0)