Log In  

Cart #fitahinigu-3 | 2021-02-23 | Code ▽ | Embed ▽ | Forks ▽ | License: CC4-BY-NC-SA

There's something weird going on here; using ..= along with a single-line if-then-end statement causes a syntax error that makes no sense:

syntax error line 16 (tab 0)
if x<2 then bad..="1" end
')' expected near 'end'

I've included 4 similar test cases that don't trigger this bug

My pico-8 version is 0.2.2 (stat(5)==30)

P#88031 2021-02-23 00:17

The ..= operator is a "shorthand" operator specific to PICO-8. These are implemented internally as a textual transform to the equivalent Lua 5.2 expression, so they come with some restrictions. According to the manual (pico-8.txt), "Shorthand assignment operators can ... be used if the whole statement is on one line." So using this operator on the same line as other keywords is not guaranteed to work.

I don't know the exact textual transform being used, but it's easy to see how PICO-8 may be trying to wrap the right-hand side of the operator in parentheses under some conditions. This appears to work (though isn't guaranteed to, per the manual):

if x then good..=("1") end
P#88035 2021-02-23 01:27
:: alexc

Have you tried dropping the quotation marks?

if x<2 then bad..=1 end

Seems to work okay for me.

P#88042 2021-02-23 03:16

[Please log in to post a comment]

Follow Lexaloffle:        
Generated 2022-09-30 18:44:56 | 0.008s | Q:15