Emit "else" instead of "elseif true then" v1 PROPOSED

Benaiah Mischenko <benaiah@mischenko.com> writes:
Phil Hagelberg <phil@hagelb.org> writes:
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~technomancy/fennel/patches/7884/mbox | git am -3
Learn more about email & git

[PATCH] Emit "else" instead of "elseif true then" Export this patch


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

diff --git a/fennel.lua b/fennel.lua
index f68a38e..b1744a8 100644
--- a/fennel.lua
+++ b/fennel.lua
@@ -1448,7 +1448,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 "else" or fstr:format(cond)
         if branch.nested then
             emit(lastBuffer, branch.condchunk, ast)
Benaiah Mischenko <benaiah@mischenko.com> writes:
View this thread in the archives