{"record":{"id":"a7ba780daf1ba208","repo":"swc-project/swc","slug":"computed-spread-property","errorCode":null,"errorMessage":"computed spread property","messagePattern":"computed spread property","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/swc_ecma_compat_es2015/src/computed_props.rs","lineNumber":225,"sourceCode":"                                }\n                                .into(),\n                            );\n\n                            continue;\n                            // unimplemented!(\"getter /setter property\")\n                        }\n                        Prop::Method(MethodProp { key, function }) => (\n                            prop_name_to_expr(key, self.c.loose),\n                            FnExpr {\n                                ident: None,\n                                function,\n                            }\n                            .into(),\n                        ),\n                        #[cfg(swc_ast_unknown)]\n                        _ => panic!(\"unable to access unknown nodes\"),\n                    },\n                    PropOrSpread::Spread(..) => unimplemented!(\"computed spread property\"),\n                    #[cfg(swc_ast_unknown)]\n                    _ => panic!(\"unable to access unknown nodes\"),\n                };\n\n                if !self.c.loose && props_cnt == 1 {\n                    single_cnt_prop = Some(\n                        CallExpr {\n                            span,\n                            callee: helper!(define_property),\n                            args: vec![exprs.pop().unwrap().as_arg(), key.as_arg(), value.as_arg()],\n                            ..Default::default()\n                        }\n                        .into(),\n                    );\n                    break;\n                }\n                exprs.push(if self.c.loose {\n                    let left = if is_compute {","sourceCodeStart":207,"sourceCodeEnd":243,"githubUrl":"https://github.com/swc-project/swc/blob/d7d74346665e36e692aa07e13d4ee3ee692ee35c/crates/swc_ecma_compat_es2015/src/computed_props.rs#L207-L243","documentation":"The ES2015 `computed_props` pass rewrites object literals with computed keys into `_define_property` helper calls. While iterating the literal's properties it only handles KeyValue, Shorthand and Method props; a `PropOrSpread::Spread` element (object spread/rest, an ES2018 feature) reaches `unimplemented!` because the pass cannot express a spread as a defineProperty sequence.","triggerScenarios":"Run `es2015::computed_props` over an object literal containing a spread, e.g. `({ [k]: v, ...rest })`, without first lowering spreads with the ES2018 `object_rest_spread` pass.","commonSituations":"Assembling ES2015 passes manually with incomplete coverage; targeting old browsers while source uses modern syntax; pass-ordering regressions after refactoring a custom transform chain.","solutions":["Run `es2018::object_rest_spread(...)` before `es2015::computed_props(...)` in the pass chain, or use the built-in es2015 preset which already pairs them","Raise the compilation target to ES2018+ so neither pass runs","Pre-transpile object spread with another tool before feeding the code to swc"],"exampleFix":"// Rust pass chain\n// before\nlet passes = vec![computed_props(config)];\n\n// after\nlet passes = vec![object_rest_spread(config), computed_props(config)];","handlingStrategy":"validation","validationCode":"// Rust: check for spread in object literals before running computed_props\nfn object_literal_has_spread(e: &Expr) -> bool {\n    matches!(e, Expr::Object(ObjectLit { props, .. })\n        if props.iter().any(|p| matches!(p, PropOrSpread::Spread(..))))\n}","typeGuard":"fn is_supported_by_computed_props(props: &[PropOrSpread]) -> bool {\n    props.iter().all(|p| !matches!(p, PropOrSpread::Spread(..)))\n}","tryCatchPattern":null,"preventionTips":["Always pair es2015::computed_props with es2018::object_rest_spread, or use the preset builders which order passes correctly","Smoke-test the pipeline on inputs using modern syntax before batch processing"],"tags":["ecmascript","es2015","compat","pass-ordering","object-spread"],"backgroundTag":null,"analyzedSha":"d7d74346665e36e692aa07e13d4ee3ee692ee35c","analyzedAt":"2026-08-16T12:41:13.160Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}