prevwong/reka.js

Regression: Variable Declaration Inside rekajs Internal Function Breaks it

Closed this issue · 2 comments

K1NZ54 commented

After the latest updates, it seems that variable declarations within rekajs internal functions are not working as expected. I was able to verify this behavior against an older version where it worked as expected.

Reproduction Steps:

Create a rekajs internal function as follows:

() => {
  val test = 10; 
  counter = test; 
  $confetti(); 
}

Expected Behavior:

The variable test should be assigned the value "10", counter should be set to "10", and $confetti() should be called, triggering the confetti animation.

Actual Behavior:

The variable alors and counter assignments seem not to work, and $confetti() is not called.

K1NZ54 commented

I've noticed another bug related to global variable handling. While the function $alert(variable) works as expected when using a global variable variable, assigning its output to a new variable (e.g., let newVar = $alert(variable);) seems to break the functionality.

Reproduction Steps:

Declare a global variable:
val variable = "test";

Call $alert(variable); this works as expected.

Try assigning the function call to a new variable:

let newVar = $alert(variable);

Expected Behavior:

The $alert() function should display the alert with the content of the global variable variable, and the output should be assigned to newVar.

Actual Behavior:

The function call $alert(variable) fails to execute properly when its output is being assigned to newVar.

Workaround:

Direct function calls to $alert(variable) without assignment to another variable work as expected. Additionally, using a string directly as in let newVar = $alert("variable"); works.

EDIT : if we use a variable in a function like it it's broken :

() => {
 let newValue = test; 
 $confetti
}

LOG : Error: Value for "test" not found in scope

image

Pushed a fix, but don't think this is a regression? The resolver never resolves any variable declarations inside a function until now.