Closed Sophismata closed 2 years ago
I can't reproduce State.setVar()
doing anything wrong, with SC 2.35.0. What I can reproduce is this line giving you the impression the value is wrong:
<p>$$foo: "<<= $foo>>" (<<= typeof $foo>>)<br>...</p>
What happens the first time this is run is that $foo
evaluates to "$bar"
, and since the $bar
variable doesn't exist yet this gets printed verbatim, as per the naked variable syntax. The second time around $bar
exists, so its value gets printed instead.
Internal variables are still correct though, which can be checked via the console.
Thanks, that's good to hear. I'll check tonight & confirm — I'd thought the console reflected the results I'd seen but I could be mistaken.
@Sophismata Can this issue be closed?
Describe the bug. When a
<<run>>
or<<set>>
macro is used withState.setVar()
— e.g. to dynamically set a variable who's name is referred to by a second variable — both variables have their values changed.To Reproduce: Example passage text displaying this behaviour:
Expected behaviour. Executing
<<run State.setVar($foo, Math.PI)>>
should change the value of variable$bar
to Math.PI. The value of variable$foo
should not be changed.Actual behaviour. Both
$foo
and$bar
are changed. Additionally,$foo
is not set toMath.PI
, but the stringified outcome ofMath.PI
(as this is happening while the macro is being parsed).Project details.
Desktop details.