Skip to content

Commit 5c409cf

Browse files
committed
improve Block's tostring
1 parent df7ca32 commit 5c409cf

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

moonscript/compile.lua

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,13 @@ Block = (function()
110110
export_all = false,
111111
export_proper = false,
112112
__tostring = function(self)
113-
return "Block<> <- " .. tostring(self.parent)
113+
local h
114+
if "string" == type(self.header) then
115+
h = self.header
116+
else
117+
h = self.header:render()
118+
end
119+
return "Block<" .. tostring(h) .. "> <- " .. tostring(self.parent)
114120
end,
115121
bubble = function(self, other)
116122
if other == nil then

moonscript/compile.moon

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,13 @@ class Block
5555
export_all: false
5656
export_proper: false
5757

58-
__tostring: => "Block<> <- " .. tostring @parent
58+
__tostring: =>
59+
h = if "string" == type @header
60+
@header
61+
else
62+
@header\render!
63+
64+
"Block<#{h}> <- " .. tostring @parent
5965

6066
new: (@parent, @header, @footer) =>
6167
@current_line = 1
@@ -250,7 +256,7 @@ class Block
250256
\append_list [@value v for v in *values], delim
251257

252258
stm: (node, ...) =>
253-
return if not node -- slip blank statements
259+
return if not node -- skip blank statements
254260
node = @root.transform.statement node
255261
fn = line_compile[ntype(node)]
256262
if not fn

0 commit comments

Comments
 (0)