oven-sh/bun · error · SyntaxError

Could not process input

Error message

Could not process input:
${line}
${spaces}^
    at ${filename}:${lineNumber}:${columnNumber}

What it means

SyntaxError from the directive/function scanner in bundle-functions.ts: the head of the source did not match any known top-level form (export, function, type, interface, $directive, etc.). The message reconstructs the exact line, a caret under the offending column, and the file:line:col, so the fault is a construct at that position the hand-rolled parser cannot recognize.

Solutions

  1. Go to the reported file:line:column and rewrite the construct in a form the parser recognizes (see the leading regex alternatives in the loop)
  2. Add a match arm to the parser for the new top-level construct
  3. Move unsupported syntax out of the preprocessed builtin source
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/codegen/bundle-functions.ts:136 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/602c5d3cd493bdb8. Report an issue: GitHub.

Appendix: source

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

    if (!match) {
      const pos = originalContents.length - contents.length;
      let lineNumber = 1;
      let columnNumber = 1;
      let lineStartPos = 0;
      for (let i = 0; i < pos; i++) {
        if (originalContents[i] === "\n") {
          lineNumber++;
          columnNumber = 1;
          lineStartPos = i + 1;
        } else {
          columnNumber++;
        }
        if (i === pos) {
          break;
        }
      }
      const lineEndPos = lineStartPos + originalContents.slice(lineStartPos).indexOf("\n");
      throw new SyntaxError(
        "Could not process input:\n" +
          originalContents.slice(lineStartPos, lineEndPos) +
          "\n" +
          " ".repeat(pos - lineStartPos) +
          "^" +
          "\n    at " +
          filename +
          ":" +
          lineNumber +
          ":" +
          columnNumber,
      );
    }
    contents = contents.slice(match.index!);
    if (match[1] === "import") {
      // TODO: we may want to do stuff with these
      const i = contents.indexOf(";");
      contents = contents.slice(i + 1);

View on GitHub (pinned to 8c5296ac45)