Skip to content

Cloud variables declared in sprites are emitted as sprite-local cloud variables #350

@aspizu

Description

@aspizu

Repro

tmp=$(mktemp -d /tmp/goboscript-cloud-sprite-XXXXXX)
printf 'costumes "blank.svg";\n\n' > "$tmp/stage.gs"
printf 'costumes "blank.svg";\n\ncloud score;\n\nonflag {\n    score = 1;\n}\n' > "$tmp/main.gs"
printf '<svg xmlns="http://www.w3.org/2000/svg" width="1" height="1"></svg>\n' > "$tmp/blank.svg"
cargo run --quiet -- build "$tmp"
python3 - <<'PY' "$tmp/$(basename "$tmp").sb3"
import json, sys, zipfile
with zipfile.ZipFile(sys.argv[1]) as z:
    p=json.loads(z.read('project.json'))
for t in p['targets']:
    print(t['name'], t['isStage'], t['variables'])
PY

Observed:

Stage True {}
main False {'score': ['☁ score', 0, True]}

A cloud declaration inside a sprite emits the cloud variable on that sprite target.

Expected

Cloud variables should be rejected outside the stage/global scope, or normalized to a stage/global variable. Scratch cloud variables are project-global and should not be sprite-local.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions