Skip to content

Top-level statements not re-executed per script invocation (mismatch with official client) #86

Description

@cernec1999

Summary

The Geyser VM executes top-level script statements once at load time. The official Graal client re-executes top-level statements on every script invocation (e.g. each onTimeout firing). This mismatch causes false passes in the harness.

Repro

//#CLIENTSIDE
mem = new[4];

function onCreated() {
  mem[0] = 10;
  setTimer(0.5);
}

function onTimeout() {
  showtext(200, 10, 10, "Arial", "", "mem[0]=" @ mem[0]);
  changeimgvis(200, 6);
  mem[0] = mem[0] + 1;
  setTimer(0.5);
}

Expected (official client)

Frame 1 shows mem[0]=10, then every frame shows mem[0]=0 (or blank) — top-level mem = new[4] re-runs before each invocation, wiping the array.

Actual (Geyser VM)

Frames show mem[0]=10, 11, 12, 13... — top-level ran once at load, the array persists.

Impact

This masked a real bug in wasm2gs2-generated code: the transpiler emitted mem = new[16] at top-level, which the official client wiped on every frame (ball/paddles stuck at 0,0). The harness showed it working because Geyser never re-ran the top-level reset. Moving the allocation into onCreated() (fires once) fixed it on official.

Suggested fix

Re-execute top-level statements before each event dispatch (onTimeout, onCreated, etc.), matching official client semantics.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions