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

Benaiah Mischenko: 1
 Emit "else" instead of "elseif true then"

 1 files changed, 2 insertions(+), 1 deletions(-)
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/7888/mbox | git am -3
Learn more about email & git
View this thread in the archives

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

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)