Skip to content

check-cross-package-test-inputs: NEW_URL_LITERAL has the same interpolating-template blind spot #11487 fixed for PATH_LITERAL #12085

Description

@yinlianghui

Found while implementing #11487 (PR to follow) — measured on origin/main at 402113d57, not reasoned.

#11487 fixed PATH_LITERAL (scripts/check-cross-package-test-inputs.mjs) so a backtick argument containing ${ is treated as unreadable — no name, depth preserved — instead of being walked as one ordinary descent. NEW_URL_LITERAL, three lines above it, has the identical character class ([^'"]*) and the identical blind spot, in a structurally different call path (new URL(rel, import.meta.url)seeds, notresolve/join` arguments), and #11487's fix does not touch it — deliberately out of scope there.

What is measured

constNEW_URL_LITERAL=/^new\s+URL\(\s*(['"`])([^'"`]*)\1\s*,\s*import\.meta\.url\s*,?\s*\)$/;

matches an interpolating template the same way PATH_LITERAL did:

node-e '
constNEW_URL_LITERAL=/^new\s+URL\(\s*([\x27"\x60])([^\x27"\x60]*)\1\s*,\s*import\.meta\.url\s*,?\s*\)$/;console.log("new URL(`${someVar}`, import.meta.url)".match(NEW_URL_LITERAL));
'
# =>matches,capturingcontent"${someVar}"

The captured content is fed straight into walkLiteral(hereDepth, url[2], dirSegs) (no intervening "can I read this" branch — that branch only exists inside pathExpression()'s resolve/join argument loop, which NEW_URL_LITERAL does not go through). ${someVar} is walked as one ordinary path segment, so:

Unlike the PATH_LITERAL call site, an unmatched NEW_URL_LITERAL does not fall into an explicit "cannot read, keep depth" branch — pathExpression() just returns undefined for the whole new URL(...) expression (the same outcome as any other unrecognised seed shape, already accepted and self-tested at "does NOT flag a read argument that is an unrecognised expression"). So the fix shape is likely the same narrowing (reject a backtick literal containing ${), but the consequence of matching a template today is not "wrong depth kept" so much as "the whole seed is silently misread instead of being silently unrecognised" — worth its own triage read rather than assuming #11487's exact disposition applies unchanged.

Why this is a finding rather than a defect card

No test in the tree spells a new URL() seed with interpolation today (a search for NEW_URL_LITERAL returns exactly the two lines above), so nothing is currently mis-verdicted — this is a property of the detector, not an outage, same as #11487 was.

Refs: #11487 (the PATH_LITERAL fix this is the sibling of, same file, same character-class shape) · #9763 (the reconstruction that introduced the RESOLVED half and walkLiteral).


Generated by Claude Code

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions