tmedwards / sugarcube-2

SugarCube is a free (gratis and libre) story format for Twine/Twee.
https://www.motoslave.net/sugarcube/2/
BSD 2-Clause "Simplified" License
177 stars 41 forks source link

Spread syntax with story/temporary variables causes TwineScript error #227

Closed AlyxMS closed 2 months ago

AlyxMS commented 1 year ago

Describe the bug. Using spread syntax without a space (I.E. [...$var]) causes issues. But using a space to separate does not. (I.E. [... $var])

To Reproduce: Example: Attempting to convert a Set to Array. $set is a Set variable.

<<set setup.setToArray = function (set) { return [...set] }>>
<<set _arr = setup.setToArray($set)>>
This would work.

<<set setup.set = $set>>
<<set _arr = [...setup.set]>>
This would work as spread is not used on a story or temporary variable.

<<set _arr = [... $set]>>
This works. A space is used to separate the spread syntax.

<<set _arr = [...$set]>>
This errors out "$set is not defined".

Expected behavior. Spread syntax should work with story or temporary variables even if there is no space separating them.

Project details.

Desktop details.

Additional context. Problem is rather minor, just posting it for good measure.

AlyxMS commented 1 year ago

Point taken, it's called spread syntax not "spread operator" :D Appreciate the fix!

tmedwards commented 1 year ago

WAT? Oh. The edits. That's just for my own OCD. It is a syntax, rather than an operator, so call a spade a spade and all that.

ChapelR commented 1 year ago

you must craft the perfect title before you close this and never look at it again