~technomancy/fennel

[BUG] Bad lua code generated when calling a method on a table literal

Details
Message ID
<87o906gxkc.fsf@hector.i-did-not-set--mail-host-address--so-tickle-me>
DKIM signature
fail
Download raw message
DKIM signature: fail
The following fennel code generates bad Lua:

(: {:foo (fn [self] (print self.bar)) :bar :baz} :foo)

It compiles to the following:

local function _0_(self)
  return print(self.bar)
end
return {bar = "baz", foo = _0_}:foo()

As you can see on the last line, the table literal is immediately
followed by a method call. This is not valid Lua - the table literal
should be surrounded with parens, as follows:

local function _0_(self)
  return print(self.bar)
end
return ({bar = "baz", foo = _0_}):foo()

The following link is to code in the implementation of the : special in
fennel.lua on master which appears to be intended to handle this case,
but it doesn't appear to be working.

https://github.com/bakpakin/Fennel/blob/2f43f19797838772061e3a0e2563b51269189f2b/fennel.lua#L1591-L1601

- benaiah