{
"jsc": {
"parser": {
"syntax": "ecmascript",
"jsx": false
},
"target": "es2022",
"loose": false,
"minify": {
"compress": {
"arguments": false,
"arrows": true,
"booleans": true,
"booleans_as_integers": false,
"collapse_vars": true,
"comparisons": true,
"computed_props": true,
"conditionals": true,
"dead_code": true,
"directives": true,
"drop_console": false,
"drop_debugger": true,
"evaluate": true,
"expression": false,
"hoist_funs": false,
"hoist_props": true,
"hoist_vars": false,
"if_return": true,
"join_vars": true,
"keep_classnames": false,
"keep_fargs": true,
"keep_fnames": false,
"keep_infinity": false,
"loops": true,
"negate_iife": true,
"properties": true,
"reduce_funcs": false,
"reduce_vars": false,
"side_effects": true,
"switches": true,
"typeofs": true,
"unsafe": false,
"unsafe_arrows": false,
"unsafe_comps": false,
"unsafe_Function": false,
"unsafe_math": false,
"unsafe_symbols": false,
"unsafe_methods": false,
"unsafe_proto": false,
"unsafe_regexp": false,
"unsafe_undefined": false,
"unused": true,
"const_to_let": true,
"pristine_globals": true
},
"mangle": false
}
},
"module": {
"type": "es6"
},
"minify": true,
"isModule": true
}
Operating System:
Platform: linux
Arch: x64
Machine Type: x86_64
Version: #37~24.04.1-Ubuntu SMP PREEMPT_DYNAMIC Thu Nov 20 10:25:38 UTC 2
CPU: (24 cores)
Models: AMD Ryzen 9 9900X 12-Core Processor
Binaries:
Node: 24.15.0
npm: 11.12.1
Yarn: 1.22.22
pnpm: 10.33.2
Relevant Packages:
@swc/core: 1.15.32
@swc/helpers: N/A
@swc/types: 0.1.26
typescript: 5.9.3
SWC Config:
output: N/A
.swcrc path: N/A
Next.js info:
output: N/A
The callback cb in the sample code is called with the correct number of arguments
Describe the bug
In the sample code, the minified code (with
compress: true, specificallyunusedorreduce_vars) doesnt call the callbackcbwith"value"but with no arguments instead.It seems to wrongly infer arity 0 for the function even though the callback is only conditionally initialized if not set.
The following things fix the incorrect minified code:
unusedandreduce_varscb = _ => trueInput code
Config
{ "jsc": { "parser": { "syntax": "ecmascript", "jsx": false }, "target": "es2022", "loose": false, "minify": { "compress": { "arguments": false, "arrows": true, "booleans": true, "booleans_as_integers": false, "collapse_vars": true, "comparisons": true, "computed_props": true, "conditionals": true, "dead_code": true, "directives": true, "drop_console": false, "drop_debugger": true, "evaluate": true, "expression": false, "hoist_funs": false, "hoist_props": true, "hoist_vars": false, "if_return": true, "join_vars": true, "keep_classnames": false, "keep_fargs": true, "keep_fnames": false, "keep_infinity": false, "loops": true, "negate_iife": true, "properties": true, "reduce_funcs": false, "reduce_vars": false, "side_effects": true, "switches": true, "typeofs": true, "unsafe": false, "unsafe_arrows": false, "unsafe_comps": false, "unsafe_Function": false, "unsafe_math": false, "unsafe_symbols": false, "unsafe_methods": false, "unsafe_proto": false, "unsafe_regexp": false, "unsafe_undefined": false, "unused": true, "const_to_let": true, "pristine_globals": true }, "mangle": false } }, "module": { "type": "es6" }, "minify": true, "isModule": true }Link to the code that reproduces this issue
https://play.swc.rs/?version=1.15.32&code=H4sIAAAAAAAAAzWOSw7DIAxE95ximhUcgu56kHycFCkxlYObRcTdCyTdWNZ71oxn5TGFyBBlGz913R1OA6yUcGIckOFxm4LDDPsYB3c5D%2Bvgn0iihFy0UFLhomz37VelzplsTA2vmQU3ejVcYQ3Aew%2FliebANP01kN4SDzAdeIlEsd0W9j3wgl4W3YhTya93uc27vD5jKsvO%2FAD6O2%2By4AAAAA%3D%3D&config=H4sIAAAAAAAAA32UO3LjMAyG%2B5zCozrFjostcoDtcgYOTYIyvXxoCNCxJuO7L0RJtjeG3En48AMkAOL7bbfrTmi6j903f%2FLPoAtCuf2zBcdE%2BsKWDkzUaIofqHtf6Qkn5HRAaKbrTDrSpQdqKtz%2F2u8XRRdyRlgViy365N34mNPkOBRAfLCxlUPWCInwf%2F3CSv6aAJX6aD%2FkHECnF0RpVD4R9FCkwCaHoAcEddZFiDKdVBePWUoxwUpg1VDyIPJkPfmcOOcztaCtMtmCgHwBQ%2F4MkoxzsSwhX0%2B4T8MWDrXvW59%2FqOGsQ9Uk5IRLawmfVoh6zB5JuZqkEs5wowYzXIr7U%2BmdKkC1pGfdKfu00ZO%2FAFyBoBGTjiDFbR6O52lL7V4qfXI8sjQKnOdbumWCnouqvHdCZafKQCEvdbOArQamyhrpOAveKB96Cwqc41kRQuOXJ3OUktI4QHYC4P5qJ03VDNTtFW7w6UG8wH%2F4liQP2OIRNR23KY7xkMOLBBHomO0LB24F5W1ceEtchm1ekwUeDbCiS8UGnpcAPwDKKrR9%2BTQb%2FDw4oupDPtzXxOJwve3hqFN%2Ff%2B%2FzKn5bHLqYbW1wWfJTf%2BfV%2FLu7O61beD1B5%2FFzFbac13%2FKOhgeLwYAAA%3D%3D
SWC Info output
Expected behavior
The callback cb in the sample code is called with the correct number of arguments
Actual behavior
The callback is called with no arguments in the minified code
Version
1.15.32
Additional context
No response