Repository navigation
prelude: add Math.fmod - #1711
Merged
Merged
Conversation
Adds Math.fmod(val, divisor): Float to the stdlib Math module, bound to
the libm fmod symbol via @cpp_extern("fmod"). There is no llvm.fmod.f64
intrinsic (fmod is LLVM's frem opcode, not an intrinsic), so the libm
symbol is bound directly: natively it resolves through libm, and on wasm
llc lowers the call to an fmod import, provided by the JS runtime as
(v, d) => v % d (JS % is the truncated remainder, matching C fmod).
std bumped to 0.7.0 (minor: new prelude API).
Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
mbouaziz
enabled auto-merge
November 19, 2026 01:15
mbouaziz
added a commit
that referenced
this pull request
Nov 19, 2026
Dependabot bumps in examples/cache_invalidation/edge_service and examples/blogger/reactive_service raised @types/node/typescript/eslint ranges without a matching root lock update, so `npm ci` at the repo root fails with EUSAGE and the docs workflow's build job is red on main and on every PR touching skiplang/**/ts/**/src/** (e.g. #1711). Regenerated with `npm install --package-lock-only`. Validated with `npm ci --ignore-scripts --no-audit --no-fund --dry-run` at the root (passes now, EUSAGE on unmodified main) and `npm ci --dry-run` in www/. Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
mbouaziz
added a commit
that referenced
this pull request
Nov 19, 2026
…1713) ## Summary Regenerates the root `package-lock.json` so it satisfies all workspace `package.json` files. This un-breaks the `docs` workflow's `build` job, which has been red on `main` and on PRs since the dependabot bumps below landed. ## Root cause Dependabot commits bumped dependency ranges in workspace examples without a matching root lock update: - `examples/cache_invalidation/edge_service/package.json`: `@types/node ^26.6.6`, `typescript ^6.0.3`, `eslint 10.15.0` (e607811 and follow-ups) - `examples/blogger/reactive_service/package.json`: similar bumps The root lock still pinned `@types/node 20.19.9` / `typescript 5.9.3` under those workspaces, so `npm ci` at the repo root fails with: ``` npm error code EUSAGE `npm ci` can only install packages when your package.json and package-lock.json are in sync. Invalid: lock file's @types/node@20.19.9 does not satisfy @types/node@26.6.6 Missing: eslint@10.15.0 from lock file ... ``` The docs workflow runs root `npm ci` on PRs touching `www/**`, `skipruntime-ts/**/src/**`, or `skiplang/**/ts/**/src/**` — which is why #1711 (touching `skiplang/prelude/ts/wasm/src/sk_runtime.ts`) showed a red `build` check even though its CircleCI checks were all green and it merged (docs is not a required check; required checks are the CircleCI contexts only). ## Fix `npm install --package-lock-only --ignore-scripts` at the root. Only `package-lock.json` changed (+919/-162): nested entries for the bumped example workspaces, e.g. `examples/cache_invalidation/edge_service/node_modules/@types/node` now 26.6.6. The lock's top-level metadata (`name: "skip"`, `lockfileVersion: 3`) is unchanged — regenerated in a directory whose name differs from the repo root, so the `name` field was explicitly restored. ## Validation - On unmodified `main` (4b3ad39): `npm ci --ignore-scripts --no-audit --no-fund --dry-run` fails with the EUSAGE above. - On this branch: the same command exits 0; `npm ci --no-audit --no-fund --dry-run` in `www/` (separate lock) also exits 0. - End-to-end: triggered the `docs` workflow on this branch via `workflow_dispatch` — the `build` job (root `npm ci`, TS package builds, docusaurus site build) completed **success** (run 44440100236; the `deploy` job fails on manual runs since Pages isn't configured for `workflow_dispatch`, which is expected and unrelated). AI assistance: prepared with Mistral Vibe; the commit carries a Co-Authored-By trailer.
mbouaziz
added a commit
to SkipLabs/skjs
that referenced
this pull request
Nov 19, 2026
…carries a Float (#1077) Simplifies the number-literal machinery now that the Skip stdlib provides Ryu-based `Float.toString` (shortest round-trip, SkipLabs/skip#1288) and `Math.fmod` (SkipLabs/skip#1711): - `jsNumberToString` / `shortestFloatDigits` are now total: Ryu's shortest digits always read back to the same double, so the round-trip guard is gone - Enum constant folding carries doubles end-to-end: `EFNum(Float)` instead of `EFNum(String)`; the literal name is produced by `jsNumberToString` only when a member value is materialized - JS `%` over doubles folds with `Math.fmod` (exactly the truncated remainder with the dividend's sign, NaN cases included), replacing a hand-rolled Sterbenz loop; `enumDoubleInt32Base` uses it too No behavior change: full test suite passes (230 tests), and the checker binary produces identical results to the previous one on positive/negative enum-folding and literal-naming repros. New pins: `jsNumberToString` unit test and enum remainder cases (`5.5 % 2 = 1.5`, `-5.5 % 2 = -1.5`, `1e309 % 2 = NaN -> number`), verified against `tsc --strict`. Version bumped to 1.26.3 per the every-PR rule. Generated by Mistral Vibe (co-authored with the commit via `Co-Authored-By: Mistral Vibe <vibe@mistral.ai>`).
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.
Summary
Adds
Math.fmod(val: Float, divisor: Float): Floatto the stdlibMathmodule (Cfmodsemantics: the result has the sign of the dividend), alongsidesin/cos/pow/etc.Motivation
The stdlib had no floating-point remainder operation;
fmodis needed for e.g. wrapping angles/phases. It is added at the stdlib level (like the other math functions) rather than as a language operator, so no compiler changes were required.Implementation notes
skiplang/prelude/src/stdlib/other/Math.sk:@cpp_extern("fmod") native fun fmod(...). Note there is nollvm.fmod.f64intrinsic (fmod is LLVM'sfremopcode, not an intrinsic), so the libm symbol is bound directly: natively it resolves through libm, and on wasmllc -mtriple=wasm32lowers the call to anfmodimport.skiplang/prelude/ts/wasm/src/sk_runtime.ts: provides the wasmfmodimport as(v, d) => v % d(JS%is the truncated remainder, matching Cfmod), plus theToWasminterface entry.skiplang/prelude/Skargo.toml:stdbumped 0.6.0 -> 0.7.0 (minor: new prelude API).skiplang/prelude/tests/Math.sk: new sktest suite covering signs, exact multiples, |dividend| < |divisor|, fractional divisors, and special values (+/-inf, NaN, zero divisor).Validation
Changes touch
skiplang/(prelude + wasm runtime):cd skiplang/prelude && SKTEST_JOBS=8 ../../bin/run-sktest.sh): 138/138 pass, including the two newMathTesttests.skc:fmod(5.5,2.0)=1.5,fmod(-7.0,2.0)=-1.0,fmod(5.0,1.5)=0.5,fmod(7.0,2.0)=1.0.llc -mtriple=wasm32-unknown-unknown+wasm-ld --allow-undefined: the call becomes anfmodimport, which the JS runtime now provides.skfmtandprettier --checkclean on the changed files.AI assistance: implemented with Mistral Vibe; the commit carries a Co-Authored-By trailer.