Repository navigation
fix(hir): #925 — unimplemented-API errors point at the supported replacement - #935
Merged
Merged
Conversation
For two error shapes that the user spends 15 minutes diagnosing:
1. `crypto.hmacSha256(data, key)` now points at
`crypto.createHmac("sha256", key).update(data).digest("hex")`.
2. `require("jose")` distinguishes "in stdlib, swap to ESM" from
"not in stdlib at all — static import compiles but every call is
undefined at runtime" (vs. `require("crypto")`).
New `crates/perry-hir/src/lower/unimpl_hints.rs` keys (module, prop)
and require-specs to a narrow hint table; the three existing #463
emission sites and the #668 `require()` rejection append the hint when
one is available. Generic "see `perry --print-api-manifest`" message
still fires for everything not on the explicit list. 7 unit tests
cover the lookup matrix.
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
crates/perry-hir/src/lower/unimpl_hints.rs) that the Compile-time error for unimplemented Node / Web APIs #463 unimplemented-API gate + AOT:require('./mod')from inside a class method returns a non-callable value #668require()rejection consult and append to their existing error messages.crypto.hmacSha256andrequire()for crypto/jose — error messages don't suggest the supported replacement clearly enough #925 calls out by name; everything else still falls back to the generic "seeperry --print-api-manifest" pointer.crypto.hmacSha256→crypto.createHmac("sha256", key).update(data).digest("hex").require("crypto")/require("node:crypto")→ "in stdlib, swap to ESMimport * as crypto from \"node:crypto\"".require("jose")→ "not in stdlib, static import compiles but every call isundefinedat runtime".Test plan
lower::unimpl_hints::testscovering the lookup matrix (pass)./tmp/test_925_crypto_hmac.ts,/tmp/test_925_require_jose.ts, and arequire("crypto")fixture; confirm each error message carries the trailing hint sentence.cargo build --release -p perry-hir -p perryclean.cargo fmtclean.Cargo.toml/CLAUDE.md/Cargo.lockafter rebase onto currentmain.