fix(playground): repair stale/broken examples + faithful example verifier#1
Merged
Conversation
…fier faithful The deployed playground examples had drifted from current Silicon syntax, and several "examples" didn't actually do what they claimed: - Snake: was a counter that never drew anything — now a real, playable snake (growing tail + self-collision + food) drawn on the canvas each tick. The body lives in raw linear memory (WASM::i32_store/load); arrow keys steer, Space restarts. Input is latched into a per-tick `pend` turn so two fast key presses can't fold the head 180° into the neck, and food is placed only after the body is fully advanced so it never lands on the snake or reads an unwritten slot. - HTML list: only console-logged — now builds an HTML <ul> and renders it into the render panel via web::set_html. - wasm_gc (Option): used the removed `pattern => body` @match arm — now the flat @match(o, $Some v, { v }, $None, { dflt }) form. - INITIAL_SOURCE (default editor doc): used the dropped `&` call sigil + @Local — now mirrors hello_world's paren-call syntax. - Cheatsheet: documented the removed `=>` @match form — fixed to the flat form. - gc_vec: was configured for --target=wasm-gc, but `@use 'vec'` is the linear-memory impl (alloc/realloc, rejected under wasm-gc), so it never compiled in the deployed playground. Relabeled to the host target. - server.ts (local dev server): never inlined `@use`, so the five stdlib/vec examples failed at /compile. Now calls inlineStdlibUses() before parse, mirroring the browser build (web/entry.ts). verify-examples.ts now extracts EXAMPLE_FEATURES/EXAMPLE_TARGETS and compiles each example with the exact features + target the UI uses (it previously used features:[] with no target, which masked the gc_vec break). All 19 examples pass verify-examples and the headless-Chromium smoke test (compile + run-in-UI). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ntax The static design/roadmap pages served alongside the playground (plan.html, features-plan.html, modules-plan.html) still showed pre-ADR-0020 Silicon that the current compiler rejects. Modernized every Silicon snippet (code blocks, inline <code> refs, and diff illustrations) while preserving the HTML, syntax-highlight markup, and prose: - dropped the retired `&` call sigil → parenthesised calls (foo(a, b)) - @let → @fn (functions) or bare `name := v` (consts); @var → @mut; @Local → bare locals - inline `name:Type` param annotations → bare params (inference) - old `@extern name arg:Type;` / `@extern name (a:T) -> R;` → `\\ @extern name (Types) -> Ret;` - `;`-style comments in Silicon blocks → `#` (Silicon's comment char) - `A && B` (no && operator) → nested @if; retired `@stratum_operator` example → current `@stratum { Compiler::register::operator(...) }` form; grammar note now cites `ExprEnd = Primary { CallSuffix }` Verified: each modernized <pre> Silicon block parses under the current grammar (typecheck failures on fragments that reference undefined modules are expected), HTML tags stay balanced, and the pages render correctly. platforms-plan.html is unchanged — its `@platform` snippets are proposed (not yet implemented) syntax, not retired forms. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
The deployed playground's examples had drifted from current Silicon syntax, and several "examples" didn't actually do what they claimed. This repairs them so every dropdown example compiles and behaves as advertised.
Examples fixed
console_log'd<ul>and renders it into the panel viaweb::set_html.pattern => body@matcharm@match(o, $Some v, { v }, $None, { dflt }).INITIAL_SOURCE)&call sigil +@localhello_world's paren-call syntax.=>@matchformVec[Int](gc_vec)--target=wasm-gc, but@use 'vec'is the linear-memory impl (alloc/realloc, rejected under wasm-gc) → never compiled in the deployed playgroundhosttarget (compiles + runs → 55).Snake internals
The snake body lives in raw linear memory (
WASM::i32_store/i32_loadat a fixed base;tick()never allocates, so it can't collide with the bump allocator). Two robustness fixes from review:pendturn, applied once at the top oftick()— so two fast key presses can't fold the head 180° into the neck.Tooling
web/verify-examples.tsnow extractsEXAMPLE_FEATURES/EXAMPLE_TARGETSand compiles each example with the exact features + target the UI uses. The old harness compiled everything withfeatures: []and no target, which is what masked thegc_vecbreak.server.ts(local dev server) now callsinlineStdlibUses()beforeparse, mirroring the browser build — previously the five@use-based examples failed at/compileon the dev server.Verification
bun run --cwd playground verify→ example verifier: 19/19 compile with their real features/targets.bun run --cwd playground smoke→ headless Chromium: 19/19 compile and run in the real UI (game loop,set_html, wasm-gc), zero page errors.Deploy
Vercel builds this directory's static client-side bundle (
bun run build→dist/). Merging tomainships the fix to production.Follow-up (not in this PR)
playground/playground/*-plan.html(design/plan pages served statically) still contain pre-ADR-0020 snippets (&sigil,@local). They're illustrative design docs, not interactive examples — worth a separate cleanup pass or an "archived" banner.🤖 Generated with Claude Code