{"record":{"id":"e1905feebe426c18","repo":"swc-project/swc","slug":"decorators-can-t-be-placed-on-different-accessors","errorCode":null,"errorMessage":"Decorators can't be placed on different accessors with for the same property (${element.key}).","messagePattern":"Decorators can't be placed on different accessors with for the same property \\((.+?)\\)\\.","errorType":"exception","errorClass":"ReferenceError","httpStatus":null,"severity":"error","filePath":"crates/swc_ecma_transforms_base/src/helpers/generated/_decorate.rs","lineNumber":62,"sourceCode":"    var newElements = [];\n    var isSameElement = function isSameElement(other) {\n        return other.kind === \"method\" && other.key === element.key && other.placement === element.placement;\n    };\n\n    for (var i = 0; i < elements.length; i++) {\n        var element = elements[i];\n        var other;\n\n        if (element.kind === \"method\" && (other = newElements.find(isSameElement))) {\n            if (_isDataDescriptor(element.descriptor) || _isDataDescriptor(other.descriptor)) {\n                if (_hasDecorators(element) || _hasDecorators(other)) {\n                    throw new ReferenceError(\"Duplicated methods (\" + element.key + \") can't be decorated.\");\n                }\n                other.descriptor = element.descriptor;\n            } else {\n                if (_hasDecorators(element)) {\n                    if (_hasDecorators(other)) {\n                        throw new ReferenceError(\"Decorators can't be placed on different accessors with for \" + \"the same property (\" + element.key + \").\");\n                    }\n                    other.decorators = element.decorators;\n                }\n                _coalesceGetterSetter(element, other);\n            }\n        } else {\n            newElements.push(element);\n        }\n    }\n\n    return newElements;\n}\nfunction _hasDecorators(element) {\n    return element.decorators && element.decorators.length;\n}\nfunction _isDataDescriptor(desc) {\n    return desc !== undefined && !(desc.value === undefined && desc.writable === undefined);\n}","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/swc-project/swc/blob/5176682b65416c6b5de6b47379ae1588ea3ecb3f/crates/swc_ecma_transforms_base/src/helpers/generated/_decorate.rs#L44-L80","documentation":"When the napi `transform` function receives a plain string it treats it as a filename and loads the file from disk with c.cm.load_file(...).expect(\"failed to load file\"). Any I/O failure (missing file, unreadable, wrong path) panics in Rust, which napi-rs converts into a JS exception carrying this message. The panic occurs inside try_with, but because expect aborts rather than emitting to the handler, the JS side gets the raw panic instead of a structured diagnostic.","triggerScenarios":"Calling transform('some/file.js', opts, false) from @swc/core-style code where the first argument is a path string and that path does not exist or is not readable; passing a filename when you meant to pass program JSON (the object form takes a different branch); relative paths resolved against an unexpected process cwd.","commonSituations":"Calling the low-level binding with the same arguments as the high-level @swc/core transform (which accepts either code or path but validates first); monorepo tools resolving paths relative to the package root while the process cwd is the workspace root; deleted or renamed files still referenced by a manifest.","solutions":["Check the file exists and is readable (fs.existsSync / fs.accessSync) before calling transform with a path.","If you meant to transform source you already hold, pass the program-object form of the first argument instead of a bare string, or use a parse-then-transform flow.","Use absolute paths (path.resolve) so behavior does not depend on process.cwd.","Wrap the call in try/catch; the JS exception message includes 'failed to load file' with the underlying io error context."],"exampleFix":"// before: bare string path that may not exist\nconst out = transform('src/app.ts', opts, false);\n\n// after: resolve and check first\nconst file = path.resolve('src/app.ts');\nif (!fs.existsSync(file)) throw new Error(`missing input: ${file}`);\nconst out = transform(file, opts, false);","handlingStrategy":"validation","validationCode":"import fs from 'node:fs';\nimport path from 'node:path';\n\nfunction transformFileSafe(input, opts) {\n  if (typeof input === 'string') {\n    const file = path.resolve(input);\n    if (!fs.existsSync(file)) {\n      throw new Error(`transform target does not exist: ${file}`);\n    }\n    fs.accessSync(file, fs.constants.R_OK);\n    return transform(file, opts, false);\n  }\n  return transform(input, opts, false); // program-object form\n}","typeGuard":"function isTransformFilename(v: unknown): v is string {\n  // The binding treats ANY plain string as a filename.\n  return typeof v === 'string';\n}","tryCatchPattern":"try {\n  out = transform(input, opts, false);\n} catch (e) {\n  if (/failed to load file/.test(String(e?.message))) {\n    throw new Error(`swc could not load the input file: ${input}`, { cause: e });\n  }\n  throw e;\n}","preventionTips":["Remember the string overload means 'path', not 'code' - pass program objects for in-memory transforms.","Prefer absolute paths and verify existence before calling.","Catch the JS-side panic and rethrow with the offending path for actionable logs."],"tags":["swc","napi","file-io","node-bindings","panic","transform"],"backgroundTag":"file-not-found","analyzedSha":"5176682b65416c6b5de6b47379ae1588ea3ecb3f","analyzedAt":"2026-08-17T16:16:52.067Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}