feat(stdlib): close 6 STEP-3 Deno-ESM gaps surfaced by TS→AS ports (Refs #239, #242)#504
Open
hyperpolymath wants to merge 1 commit into
Open
feat(stdlib): close 6 STEP-3 Deno-ESM gaps surfaced by TS→AS ports (Refs #239, #242)#504hyperpolymath wants to merge 1 commit into
hyperpolymath wants to merge 1 commit into
Conversation
…efs #239, #242) Closes the smallest, safest tractable gaps that the four merged STEP-2 ports (phronesis#19, session-sentinel#25, tropical-resource-typing#15, nafa-app#23) flagged for STEP 3 (campaign #239): Stdlib (`stdlib/Deno.affine`): + `statIsFile` — `Deno.statSync(p).isFile` (gap 3) + `statIsDirectory` — `Deno.statSync(p).isDirectory` (gap 3) + `bytesLength` — `(b).length` (gap 4) + `bytesByteAt` — `(b)[i]` (gap 4) + `bytesAsciiSlice` — `String.fromCharCode(...(b).slice(start, end))` (gap 4) + `importMetaUrl` — `import.meta.url` (gap 5) Stdlib (`stdlib/string.affine`): ! `ends_with` is now `pub` so consumers can `use string::{ends_with};` instead of inlining a `string_sub`-backed helper. (gap 2) Codegen (`lib/codegen_deno.ml`): ! `StmtLet { sl_pat = PatWildcard _; … }` lowers to a bare expression statement instead of `const _ = X;`. Three back-to-back `let _ = …` discards in the same scope used to trip JS `SyntaxError: Identifier '_' has already been declared`. (gap 7) Tests: + tests/codegen-deno/deno_scripting_part2.{affine,deno.js,harness.mjs} exercises every new lowering plus the wildcard fix (11 assertions). ✓ All 353 dune-runtest tests pass. ✓ All codegen-Deno-ESM harnesses pass (`tools/run_codegen_deno_tests.sh`). Two further gaps from the STEP-2 set remain open, deliberately deferred: - gap 1 `Deno.test` extern lowering — panic-on-fail `main()` driver in the four merged STEP-2 ports works; not unblocking STEP 4. - gap 6 native TOML parser — heavier work; STEP-2 ports used regex field-presence checks where TOML was relevant. Gaps 9 (`AFFINESCRIPT_STDLIB` env discovery ladder, shipped #433) and 10 (negative integer literals, working today) were audited and confirmed already-resolved. Refs: hyperpolymath/standards#239, hyperpolymath/standards#242 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Closes the smallest, safest tractable gaps that the four merged STEP-2 TS→AffineScript ports — phronesis#19, session-sentinel#25, tropical-resource-typing#15, nafa-app#23 — flagged for STEP 3 of the estate-wide campaign (
hyperpolymath/standards#239, sub-issue#242).What lands
stdlib/Deno.affine(+6 externs)statIsFile(path) -> BoolDeno.statSync(path).isFilestatIsDirectory(path) -> BoolDeno.statSync(path).isDirectorybytesLength(b) -> Int(b).lengthbytesByteAt(b, i) -> Int(b)[i]bytesAsciiSlice(b, s, e) -> StringString.fromCharCode(...(b).slice(s, e))importMetaUrl() -> Stringimport.meta.urlThe
bytes*accessors give AffineScript first-class read access to the opaqueBytesreturned byreadFileBytesso callers can peek at file-magic / fixed-width binary headers without round-tripping throughreadTextFile(which throws on binary).importMetaUrlexposes the JS__dirname/__filenameidiom for "find my own location"; only legal at module top level, which the Deno-ESM backend's output already is.stdlib/string.affine(1 char)fn ends_with→pub fn ends_with. The function existed but was private, so the four STEP-2 ports each inlined astring_sub-backed helper instead of importing it. Gap 2.lib/codegen_deno.ml— wildcardlet _fix (gap 7)StmtLet { sl_pat = PatWildcard _; … }now lowers to a bare expression statement instead ofconst _ = X;. Three back-to-backlet _ = side()discards in the same scope tripped JSSyntaxError: Identifier '_' has already been declared. The wildcard pattern doesn't bind, so dropping the binding entirely preserves AffineScript semantics (evaluate for side effects).Tests
tests/codegen-deno/deno_scripting_part2.{affine,deno.js,harness.mjs}— 11 assertions across the new lowerings + the wildcard fix. The harness reaching its discard-chain assertion is itself the test for gap 7: a syntax-error generated module would have thrown at the dynamicimportline before any assert ran.Verification
dune build bin/main.exedune runtest./tools/run_codegen_deno_tests.shWhat does not land here (deferred deliberately)
Deno.testextern lowering. The four merged STEP-2 ports use a panic-on-failmain()driver and it works; not unblocking STEP 4.Gaps 9 (
AFFINESCRIPT_STDLIBenv discovery ladder, shipped #433) and 10 (negative integer literals, verified working in all contexts — match arms, array literals, equality, ternaries) were audited as already-resolved.Refs
hyperpolymath/standards#242(STEP 3 of#239).#243, mid-tier 4-9 file ports) and STEP 5 (#244, idaptik DLC) for any consumer that needs stat predicates, byte accessors, module-URL inspection, the publicends_with, or multiplelet _discards in a single scope.🤖 Generated with Claude Code