Skip to content

Commit

Permalink
handle an ambiguity case for generated code
Browse files Browse the repository at this point in the history
  • Loading branch information
leafo committed Jan 14, 2012
1 parent 260b17a commit b4d6f59
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion moonscript/compile.lua
Expand Up @@ -274,7 +274,8 @@ Block = (function()
_insert_breaks = function(self)
for i = 1, #self._lines - 1 do
local left, right = self._lines[i], self._lines[i + 1]
if left:sub(-1) == ")" and right:sub(1, 1) == "(" then
local lc = left:sub(-1)
if (lc == ")" or lc == "]") and right:sub(1, 1) == "(" then
self._lines[i] = self._lines[i] .. ";"
end
end
Expand Down
3 changes: 2 additions & 1 deletion moonscript/compile.moon
Expand Up @@ -186,7 +186,8 @@ class Block
_insert_breaks: =>
for i = 1, #@_lines - 1
left, right = @_lines[i], @_lines[i+1]
if left\sub(-1) == ")" and right\sub(1,1) == "("
lc = left\sub(-1)
if (lc == ")" or lc == "]") and right\sub(1,1) == "("
@_lines[i] = @_lines[i]..";"

render: =>
Expand Down

0 comments on commit b4d6f59

Please sign in to comment.