{"record":{"id":"14320e5aefb1953e","repo":"oven-sh/bun","slug":"could-not-parse-function-name-contents-slice-0","errorCode":null,"errorMessage":"Could not parse function name:\n${contents.slice(0, contents.indexOf(\"\\n\"))}","messagePattern":"Could not parse function name:\n(.+?)","errorType":"exception","errorClass":"SyntaxError","httpStatus":null,"severity":"error","filePath":"src/codegen/bundle-functions.ts","lineNumber":200,"sourceCode":"      }\n      const name = directive[1];\n      let value;\n      try {\n        value = directive[2] ? JSON.parse(directive[2]) : true;\n      } catch (error) {\n        throw new SyntaxError(\"Could not parse directive value \" + directive[2] + \" (must be JSON parsable)\");\n      }\n      if (name === \"constructor\") {\n        directives.ConstructAbility = \"CanConstruct\";\n      } else {\n        directives[name] = value;\n      }\n      contents = contents.slice(directive[0].length);\n    } else if (match[1] === \"export function\" || match[1] === \"export async function\") {\n      // consume async token and function name\n      const nameMatch = contents.match(/^export\\s+(async\\s+)?function\\s([_a-zA-Z0-9]+)\\s*/);\n      if (!nameMatch)\n        throw new SyntaxError(\"Could not parse function name:\\n\" + contents.slice(0, contents.indexOf(\"\\n\")));\n      const async = Boolean(nameMatch[1]);\n      const name = nameMatch[2];\n      var remaining = contents.slice(nameMatch[0].length);\n\n      // remove type parameters\n      if (remaining.startsWith(\"<\")) {\n        var cursor = 1; // skip peeked '<'\n        var depth = 1; // already entered first bracket pair\n        for (; depth > 0 && cursor < remaining.length; cursor++) {\n          switch (remaining[cursor]) {\n            case \"<\":\n              depth++;\n              break;\n            case \">\":\n              depth--;\n              break;\n          }\n        }","sourceCodeStart":182,"sourceCodeEnd":218,"githubUrl":"https://github.com/oven-sh/bun/blob/8c5296ac459e8252d3cd702f3fbcbb0c249d95d5/src/codegen/bundle-functions.ts#L182-L218","documentation":"Error \"Could not parse function name:\n${contents.slice(0, contents.indexOf(\"\\n\"))}\" thrown in oven-sh/bun.","triggerScenarios":"Thrown at src/codegen/bundle-functions.ts:200 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"}