← Back to Pull requests

[js-api] Fix `AddressValueToU64`'s type errors #2275

Closed
unknown closed this pull request without merging on Oct 13, 2026 15:16 UTC
View on GitHub
unknown unknown commented on Oct 12, 2026 07:14 UTC
Author

This PR fixes two type-related errors in the AddressValueToU64 algorithm.

The algorithm AddressValueToU64(v, addrtype) converts a JavaScript value to a WebAssembly u64 ..., by performing the following steps:

1. If addrtype is i32,
    1. Let n be ? ConvertToInt(v, 32, "unsigned"), where the destination type is associated with [EnforceRange].
    ...
1. If addrtype is i64,
    1. Let n be ? ToBigInt(v).
    1. If n < 0 or n > 2^64 − 1, throw a TypeError.
    ...

1. JavaScript value vs IDL value

v here isn't a JavaScript value, but an IDL value.

It's whatever the caller's own IDL-declared AddressValue argument resolved to after WebIDL's own argument-conversion step already ran.

Both ConvertToInt and ToBigInt are defined over genuine JavaScript values, so v needs converting back before either branch uses it:

1. Let V be v, converted to a JavaScript value.

Both branches then read V instead of v.

2. BigInt vs Mathematical value

The i64 branch's range check compares n (a BigInt bound the line above via ?ToBigInt) directly against the mathematical-value literals 0/2^64 − 1, with no conversion.

According to the ECMA-262%20are%20not%20defined) standard:

Numeric operators applied to mixed-type operands (such as a Number and a mathematical value) are not defined and should be considered an editorial error in this specification.

so the range check should be:

1. If ℝ(n) < 0 or ℝ(n) > 2^64 − 1, throw a TypeError.

Diff: 215 lines (+161 / -54) across 2 files Reviewer: Ms2ger Review duration: 1922m
All Vouch review confidence checks passed
Residual risk 0.14 = Change Risk (0.37) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.37 · 215 lines diff across 2 files
0.37
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
0.17
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
60%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.322
Shallow Review Depth shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #2275"
general weight: 0.35
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 60.5% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 36.6% (MEDIUM) · Higher = larger blast radius
36.6%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 60.5% · Lower = rushed or shallow review
60.5%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 14.5% · Safe to merge
14.5%