JS WAM: compiled string literals as V.String - #4206
Open
s243a wants to merge 2 commits into
Open
Conversation
quote_wam_constant/2 spells string(Value) with outer double quotes. The shared classifier still returns atom(Name) for those tokens; JS reads wam_constant_token_is_string/1 and emits V.String. Co-authored-by: johns243a <johns243a@gmail.com>
python/go/rust/c/cpp each ran the 48-query suite green locally. Co-authored-by: johns243a <johns243a@gmail.com>
s243a
marked this pull request as ready for review
August 31, 2026 18:12
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.
D34/D35 residual: compiled
"hi"literals becomeV.Stringon the JS path without adding astring(_)Class to the shared classifier.Branched from
grok/wamjs-string-polishand extended it (net additions).INTEGRATION_PATCH.md§0 records the shared-file design.Design (safe: no new Class)
quote_wam_constant/2— Prologstring(Value)emits"..."(escape\\and"). Atoms stay bare/single-quoted; numbers unchanged.wam_classify_constant_token/2— double-quoted token → strip quotes →atom(Name). Classifier still returns onlyatom | integer | float.wam_constant_token_is_string/1— true iff the raw token has outer double quotes. Only JS reads it.constant_to_js_term/2buildsV.String(...)when that signal is true. T5 chain compares.tag === "string"; T6 atom-hash skips string tokens.Other runtimes intern the stripped name as an atom — today's behavior.
Tests (local, all green)
tests/test_wam_javascript_builtins.plincludingprobe_string_literal/string_literal_output(V.String("hi")in generated JS; Nodewriteq→"hi")tests/test_wam_javascript_lowered.plandtests/test_wam_javascript_fact_sources.plCONFORMANCE_TARGETS=python,go,rust,c,cpp→ green, no xfail (48-query classics each). scala/elixir/wat/haskell/kotlin/fsharp/r skipped here (no toolchain); CI covers them.CONFORMANCE_TARGETS=javascriptexits 0 (adapter unpatched; local 48-query stand-in 48/48)"hi"→string(X)true,atom(X)false,writeq"hi"Residuals
{a}not special-cased in writeq