sugarcube-2
sugarcube-2 copied to clipboard
Spread syntax with story/temporary variables causes TwineScript error
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.
- SugarCube Version: 2.36.1
- Compiler & Version: Tweego version 2.1.1+81d1d71
Desktop details.
- OS & Version: Windows 10 Enterprise LTSC Version 1809
- Browser & Version: Chrome 111.0.5563.66 (64 bit)
Additional context. Problem is rather minor, just posting it for good measure.
Point taken, it's called spread syntax not "spread operator" :D Appreciate the fix!
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.
you must craft the perfect title before you close this and never look at it again