oven-sh/bun · error · SyntaxError

Could not parse function name: ${contents.slice(0, contents.

Error message

Could not parse function name:
${contents.slice(0, contents.indexOf("\n"))}

What it means

Error "Could not parse function name: ${contents.slice(0, contents.indexOf("\n"))}" thrown in oven-sh/bun.

Source

Thrown at src/codegen/bundle-functions.ts:200

      }
      const name = directive[1];
      let value;
      try {
        value = directive[2] ? JSON.parse(directive[2]) : true;
      } catch (error) {
        throw new SyntaxError("Could not parse directive value " + directive[2] + " (must be JSON parsable)");
      }
      if (name === "constructor") {
        directives.ConstructAbility = "CanConstruct";
      } else {
        directives[name] = value;
      }
      contents = contents.slice(directive[0].length);
    } else if (match[1] === "export function" || match[1] === "export async function") {
      // consume async token and function name
      const nameMatch = contents.match(/^export\s+(async\s+)?function\s([_a-zA-Z0-9]+)\s*/);
      if (!nameMatch)
        throw new SyntaxError("Could not parse function name:\n" + contents.slice(0, contents.indexOf("\n")));
      const async = Boolean(nameMatch[1]);
      const name = nameMatch[2];
      var remaining = contents.slice(nameMatch[0].length);

      // remove type parameters
      if (remaining.startsWith("<")) {
        var cursor = 1; // skip peeked '<'
        var depth = 1; // already entered first bracket pair
        for (; depth > 0 && cursor < remaining.length; cursor++) {
          switch (remaining[cursor]) {
            case "<":
              depth++;
              break;
            case ">":
              depth--;
              break;
          }
        }

View on GitHub (pinned to 8c5296ac45)

When it happens

Trigger: Thrown at src/codegen/bundle-functions.ts:200 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of oven-sh/bun@8c5296ac45 (2026-08-16). Data as JSON: /api/errors/14320e5aefb1953e. Report an issue: GitHub.