feat(solo/stdlib): json_parse / json_stringify (+ fix string-literal escapes)#53
Merged
Conversation
This was referenced May 18, 2026
Adds json_parse(s)->Value and json_stringify(v)->String, backed by serde_json (promoted to a non-optional dependency of my-lang; serde derive stays behind the `serde` feature). Mapping pairs with the Map builtins (#46): object<->Record, array<->Array, integral number->Int else Float, null<->Unit. Object keys serialize sorted (serde_json's default BTreeMap), matching map_keys' deterministic ordering. Also fixes a prerequisite latent bug: the lexer stored raw string-literal slices and escape sequences were never decoded anywhere, so `"a\"b"` yielded the four chars a \ " b and json_parse("{\"k\":1}") — issue #45's own repro — was unparseable. parse_string_literal now decodes the standard escapes (\" \\ \/ \n \t \r \0, \uXXXX / \u{...}); unknown escapes pass through leniently so no previously-valid program breaks. Adds examples/json.my and integration regression tests for both the JSON round-trip (deterministic sorted keys) and string-escape decoding. Rebased onto main after #49 (Map) landed; coexists with map_* builtins. Refs #45 Refs #47 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
9e12d7a to
b6ef7b4
Compare
hyperpolymath
added a commit
that referenced
this pull request
May 18, 2026
time() only yields a Unix timestamp float; tooling that stamps generated artifacts (changelogs, scaffolds) needs a calendar date. date_today() returns the current UTC date as an ISO `YYYY-MM-DD` string. Civil date derived from SystemTime epoch seconds via Howard Hinnant's civil_from_days algorithm (public domain) — no date-crate dependency, correct for all Gregorian dates. Verified: produces 2026-05-18 today. Adds examples/date.my and an integration test asserting format/shape and a sane range (exact value depends on the wall clock). Rebased onto main after #49 (Map) and #53 (JSON) landed; coexists with the map_* / json_* builtins. Refs #45 Refs #48 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
hyperpolymath
added a commit
that referenced
this pull request
May 18, 2026
time() only yields a Unix timestamp float; tooling that stamps generated artifacts (changelogs, scaffolds) needs a calendar date. date_today() returns the current UTC date as an ISO `YYYY-MM-DD` string. Civil date derived from SystemTime epoch seconds via Howard Hinnant's civil_from_days algorithm (public domain) — no date-crate dependency, correct for all Gregorian dates. Verified: produces 2026-05-18 today. Adds examples/date.my and an integration test asserting format/shape and a sane range (exact value depends on the wall clock). Rebased onto main after #49 (Map) and #53 (JSON) landed; coexists with the map_* / json_* builtins. Refs #45 Refs #48 Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This was referenced May 18, 2026
🔍 Hypatia Security ScanFindings: 35 issues detected
View findings[
{
"reason": "Issue in quality.yml",
"type": "missing_workflow",
"file": "quality.yml",
"action": "create",
"rule_module": "workflow_audit",
"severity": "high"
},
{
"reason": "Issue in security-policy.yml",
"type": "missing_workflow",
"file": "security-policy.yml",
"action": "create",
"rule_module": "workflow_audit",
"severity": "medium"
},
{
"reason": "Action hyperpolymath/standards/.github/workflows/governance-reusable.yml@main needs attention",
"type": "unpinned_action",
"file": "governance.yml",
"action": "pin_sha",
"rule_module": "workflow_audit",
"severity": "high"
},
{
"reason": "unwrap_or(0) with dangerous default (1 occurrences, CWE-754)",
"type": "unwrap_dangerous_default",
"file": "/home/runner/work/my-lang/my-lang/_exploratory/me-scaffolding/crates/parser/src/lib.rs",
"action": "flag",
"rule_module": "code_safety",
"severity": "critical"
},
{
"reason": "expect() in hot path (80 occurrences, CWE-754)",
"type": "expect_in_hot_path",
"file": "/home/runner/work/my-lang/my-lang/_exploratory/me-scaffolding/crates/parser/src/lib.rs",
"action": "flag",
"rule_module": "code_safety",
"severity": "medium"
},
{
"reason": "unwrap() without prior check -- DoS via panic (1 occurrences, CWE-754)",
"type": "unwrap_without_check",
"file": "/home/runner/work/my-lang/my-lang/my-ssg/src/generator.rs",
"action": "flag",
"rule_module": "code_safety",
"severity": "high"
},
{
"reason": "expect() in hot path (5 occurrences, CWE-754)",
"type": "expect_in_hot_path",
"file": "/home/runner/work/my-lang/my-lang/crates/my-mir/src/lib.rs",
"action": "flag",
"rule_module": "code_safety",
"severity": "medium"
},
{
"reason": "unwrap() without prior check -- DoS via panic (26 occurrences, CWE-754)",
"type": "unwrap_without_check",
"file": "/home/runner/work/my-lang/my-lang/crates/my-fmt/src/lib.rs",
"action": "flag",
"rule_module": "code_safety",
"severity": "high"
},
{
"reason": "unwrap() without prior check -- DoS via panic (1 occurrences, CWE-754)",
"type": "unwrap_without_check",
"file": "/home/runner/work/my-lang/my-lang/crates/my-hir/src/lib.rs",
"action": "flag",
"rule_module": "code_safety",
"severity": "high"
},
{
"reason": "unwrap() without prior check -- DoS via panic (3 occurrences, CWE-754)",
"type": "unwrap_without_check",
"file": "/home/runner/work/my-lang/my-lang/crates/my-llvm/src/lib.rs",
"action": "flag",
"rule_module": "code_safety",
"severity": "high"
}
]Powered by Hypatia Neurosymbolic CI/CD Intelligence |
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.
Second Phase-2 stdlib primitive (tracker #45), unblocked by Map (#46/#49).
What
json_parse(s) -> Value/json_stringify(v) -> String, backed byserde_json(promoted to a non-optional dep ofmy-lang; serde derive stays behind theserdefeature).Record, array↔Array, integral number→IntelseFloat, string↔String, bool↔Bool, null↔Unit. Non-serializable values (functions/AI results, NaN/Inf floats) error cleanly.BTreeMap) — same deterministic ordering asmap_keys.Prerequisite bug fixed (in scope — feature is unusable without it)
The lexer stored the raw slice between quotes and escape sequences were decoded nowhere.
"a\"b"yielded the literal 4 charsa \ " b, andjson_parse("{\"k\":1}")— issue #45's own repro — could not parse.parse_string_literalnow decodes\" \\ \/ \n \t \r \0and\uXXXX/\u{...}. Unknown escapes pass through leniently (backslash dropped, char kept) so no previously-valid program changes behavior except where it was already wrong.Validation
examples/json.myruns and matches its documented output.test_eval_json_roundtrip(sorted-key round-trip) andtest_eval_string_escapes. Full suite 17 passed, 0 failed.rustfmt-clean andclippy-clean. Pre-existing fmt drift elsewhere instdlib.rsleft untouched (out of scope, consistent with PR feat(solo/stdlib): string-keyed Map/dict builtins #49).Scope notes
vscode-extension/package-lock.json(pre-existing untracked) not included.Cargo.lockis gitignored in this repo.Refs #45
Refs #47
🤖 Generated with Claude Code