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
Cross-package function using arguments returns undefined (synthetic-arguments param inflates cross-module arity) — #321 gateway #1816
A cross-package (compilePackages) function that uses arguments returns undefined for calls with fewer args than the inflated param count.
Perry appends a synthetic arguments param (name: "arguments", is_rest: true)
to any function whose body references arguments (#677). Cross-package, the
importer's param-count collection (compile.rs ~606, func.params.len()) counts that synthetic param as a real one, inflating the arity, and the
cross-module call mishandles it (the synthetic arguments is treated as a
trailing-rest collecting only args after the fixed params, instead of the full
argument list). Under-filled calls then return undefined.
Minimal repro (compilePackages)
node_modules/mypkg/src/index.ts:
exportfunctionusesArgs(a: number,b?: number): number{returnarguments.length===1 ? a : a+(basnumber);}exportfunctionnoArgs(a: number,b?: number): number{returnb===undefined ? a : a+b;}
--print-hir on the entry: usesArgs (params: 3) vs noArgs (params: 2) — the
synthetic arguments param inflates usesArgs to 3. Single-file (non-package) arguments-using functions work; only the cross-package path is broken.
Impact — the #321 (Effect framework) gateway blocker
effect's pipe and dual (the two most-used combinators) both use arguments,
so cross-package they return undefined. This cascades:
pipe(a, fn) → undefined
Effect.map / Effect.pipe → _op of undefined in the fiber runtime
S.Struct({...}) decode → _tag of undefined in ParseResult
The effect DoD (deep import, Schema init, S.Number decode, import { Effect }
barrel Effect.runSync(Effect.succeed(42))) already works (#1804/#1809/#1810/ #1811/#1812/#1815) because those paths don't depend on a pipe/arguments
result. This bug is the gateway to the rest of effect.
Fix direction
The cross-module param count + call must treat the synthetic arguments param
specially: exclude it from the user-visible arity, and populate it with the full argument list (as the same-module synthetic-arguments path does), not
as a trailing rest. Sites: compile.rs exported-func param-count collection +
the cross-module call lowering's rest/arity handling. Broad blast radius
(all cross-module calls to arguments-using functions) — needs a thorough
regression sweep.
Activity
test: add imported_func_synthetic_arguments to CompileOptions test fi…
fix(codegen): cross-module function using `arguments` returns undefin…
proggeramlug commentedon May 28, 2026
Verified fixed by PR #1817 (merged 2026-05-26). Reproduced the exact
compilePackagesshape from the issue body:All four cases (
usesArgs(5),usesArgs(5,3),noArgs(5),noArgs(5,3)) match Node.Cross-module shape locked in
test-files/test_gap_cross_module_arguments.ts; cross-package shape (compilePackages → node_modules) locked intest-files/issue_1069/. Closing as fixed.