You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
A function referenced inside its own module is a different object from the same function imported elsewhere: export function isSame(x){ return x === f } returns false for the imported f #10554
Found by the package audit (while fixing #10434) on Perry 7661bc0 (v0.5.1587→v0.5.1589 baseline), Linux x64.
A module-level function f compared by identity inside its defining module is not === to the f value an importer
receives, although two importers' views agree with each other (ns.f === f is true in the importer).
node main.ts
PERRY_NO_AUTO_OPTIMIZE=1 perry compile main.ts -o main && ./main
Expected (Node 26.5.1)
true true true
Actual (Perry)
false false true
Impact
Identity checks against a module's own exported functions are common: registries and caches keyed by function
(map.get(handler)), "is this our default implementation" checks (if (opts.serialize === defaultSerialize)), removeEventListener/off(fn) with an exported listener, memoization keyed by function, and plugin dedup. With
Perry these silently take the wrong branch or fail to remove listeners.
Notes
Reported by the fixer as caused by the cross-module inliner cloning small exported functions together with the
functions they reference (so the clone's f is a different value). Not confirmed: in this repro the result is
identical with PERRY_NO_INLINE=1 set, which may not be the right knob — check which transform/lowering gives the
in-module reference to f a different value than the export slot (in-module direct reference vs exported wrapper
closure __perry_wrap_*, or inlined clone).
Activity
fix(transform): stop cross-module inlining bundling a separately expo…