~technomancy/fennel

[PATCH v2] Emit "else" instead of "elseif true then"

Details
Message ID
<20190902042709.32147-1-benaiah@mischenko.com>
DKIM signature
pass
Download raw message
Patch: +2 -1
---
Fixes the last patch version's bad code caused by replacing "if true"
with "else"

 fennel.lua | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fennel.lua b/fennel.lua
index b07b47e..e5d18e6 100644
--- a/fennel.lua
+++ b/fennel.lua
@@ -1483,7 +1483,8 @@ SPECIALS['if'] = function(ast, scope, parent, opts)
     for i = 1, #branches do
         local branch = branches[i]
         local fstr = not branch.nested and 'if %s then' or 'elseif %s then'
-        local condLine = fstr:format(tostring(branch.cond))
+        local cond = tostring(branch.cond)
+        local condLine = (cond == "true" and branch.nested) and "else" or fstr:format(cond)
         if branch.nested then
             emit(lastBuffer, branch.condchunk, ast)
         else
-- 
2.23.0.rc1