Skip to content

Commit 2290cc3

Browse files
committed
fix(compiler): follow local aliases of module-level Intl formatters and suppress locale checks in updaters
Bug 1: A module-level implicit Intl formatter rebound to a local const (e.g. const f = format) was not reported during render because the resolveScope check required the use-site identifier to resolve in moduleScope. Replace the scope-identity gate with a moduleLevel flag set on the value object when first recorded at module scope, so aliases at any depth inherit the flag through the same object reference. Bug 2: OCTANE_STRONG_RENDER_LOCALE_FORMAT fired inside updaters and reducers because those bodies are visited as render, but the code was absent from IMPURE_MESSAGES so pureDiagnostic did not intercept it. Locale and timezone are stable across replays on the same runtime, so this is a false positive. Return false from pureDiagnostic for this code to suppress the diagnostic entirely in pure callbacks.
1 parent ca328ef commit 2290cc3

3 files changed

Lines changed: 5 additions & 5 deletions

File tree

‎packages/octane/src/compiler/strong-mode.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1636,6 +1636,7 @@ export function analyzeStrongMode(ast, source, filename, options = {}) {
16361636
function report(code, node, message, suggestions = []) {
16371637
if (insidePureCallback) {
16381638
const pure = statePolicy.pureDiagnostic(code);
1639+
if (pure === false) return;
16391640
if (pure !== null) {
16401641
code = pure.code;
16411642
message = pure.message;

‎packages/octane/src/compiler/strong-render-policy.js‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ export function createStrongRenderPolicy({
172172
recorded++;
173173
if (scope === moduleScope && value.kind === 'intl' && value.implicit) moduleFormatters++;
174174
}
175+
if (scope === moduleScope && value.kind === 'intl' && value.implicit)
176+
value.moduleLevel = true;
175177
names.set(id.name, value);
176178
}
177179
}
@@ -248,11 +250,7 @@ export function createStrongRenderPolicy({
248250
}
249251
if (moduleFormatters !== 0) {
250252
const alias = aliasValue(member.object, scope);
251-
if (
252-
alias?.kind === 'intl' &&
253-
alias.implicit &&
254-
resolveScope(scope, unwrap(member.object).name) === moduleScope
255-
) {
253+
if (alias?.kind === 'intl' && alias.implicit && alias.moduleLevel) {
256254
reportIntl(member, alias, true);
257255
return;
258256
}

‎packages/octane/src/compiler/strong-state.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ export function createStrongStatePolicy(api) {
220220

221221
/** The Strong diagnostic that replaces a render diagnostic inside an updater or reducer. */
222222
pureDiagnostic(code) {
223+
if (code === 'OCTANE_STRONG_RENDER_LOCALE_FORMAT') return false;
223224
if (code === 'OCTANE_STRONG_RENDER_SNAPSHOT_MUTATION') {
224225
return { code: STRONG_SNAPSHOT_MUTATION, message: UPDATER_MUTATION_MESSAGE };
225226
}

0 commit comments

Comments
 (0)