{"record":{"id":"85dfed09c1d63ed0","repo":"oven-sh/bun","slug":"memory-lifetime-is-ambiguous-when-returning-utf8st","errorCode":null,"errorMessage":"Memory lifetime is ambiguous when returning UTF8String","messagePattern":"Memory lifetime is ambiguous when returning UTF8String","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/codegen/bindgen.ts","lineNumber":391,"sourceCode":"      cpp.line(\"}\");\n      cpp.line(\"return JSC::JSValue::encode(JSC::jsUndefined());\");\n      break;\n    case \"basic-out-param\":\n      addCommaAfterArgument();\n      cpp.add(\"&out\");\n      cpp.line();\n      cpp.dedent();\n      cpp.line(\")) {\");\n      cpp.line(`    return {};`);\n      cpp.line(\"}\");\n      const simpleType = getSimpleIdlType(variant.ret);\n      if (simpleType) {\n        cpp.line(`return JSC::JSValue::encode(WebCore::toJS<${simpleType}>(*global, out));`);\n        break;\n      }\n      switch (variant.ret.kind) {\n        case \"UTF8String\":\n          throw new Error(\"Memory lifetime is ambiguous when returning UTF8String\");\n        case \"DOMString\":\n        case \"USVString\":\n        case \"ByteString\":\n          cpp.line(\n            `return JSC::JSValue::encode(WebCore::toJS<WebCore::IDL${variant.ret.kind}>(*global, out.transferToWTFString()));`,\n          );\n          break;\n      }\n      break;\n    default:\n      throw new Error(`TODO: emitCppCallToVariant for ${inspect(returnStrategy)}`);\n  }\n}\n\n/** If a simple IDL type mapping exists, it also currently means there is a direct C ABI mapping */\nfunction getSimpleIdlType(type: TypeImpl): string | undefined {\n  const map: { [K in TypeKind]?: string } = {\n    boolean: \"WebCore::IDLBoolean\",","sourceCodeStart":373,"sourceCodeEnd":409,"githubUrl":"https://github.com/oven-sh/bun/blob/8c5296ac459e8252d3cd702f3fbcbb0c249d95d5/src/codegen/bindgen.ts#L373-L409","documentation":"Error \"Memory lifetime is ambiguous when returning UTF8String\" thrown in oven-sh/bun.","triggerScenarios":"Thrown at src/codegen/bindgen.ts:391 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"8c5296ac459e8252d3cd702f3fbcbb0c249d95d5","analyzedAt":"2026-08-16T08:01:58.794Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}