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
185 stars 42 forks source link

variables set to undefined/Infinity do not revive properly #323

Closed Brokenstorm closed 3 months ago

Brokenstorm commented 3 months ago

Describe the bug. when the page is refreshed (F5), all variables set to undefined/Infinity are not revived properly. undefined variables are set to [ "(revive:)", "undefined" ] Infinity variables are set to null

To Reproduce:

  1. set any variable to undefined/Infinity
  2. move to another passage (to create a moment)
  3. refresh the page

Expected behavior. The variables are set to undefined/Infinity

Project details.

greyelf commented 3 months ago

Why are you assigning a value like undefined, whose purpose is to indicate that a variable / property / method / function / etc hasn't been defined yet (eg. doesn't exist), to a variable in the first place?

That value is designed to be used in comparisons to determine is something has been defined, not assignments.

If you indicate that something shouldn't exist, then it makes sense that it's existence isn't persisted or revived. After all why revived something that hasn't been defined.

Brokenstorm commented 3 months ago

Why are you assigning a value like undefined

Some macros set object value to undefined. 2.36.1 revived those object property correctly

tmedwards commented 3 months ago

@greyelf This is indeed a bug.

Fixed in 84c396d.