Discussion of the Fennel programming language for contributors and users


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

Message ID
DKIM signature
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)
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)
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.


- benaiah