{"record":{"id":"1e99192d48a7eefb","repo":"oven-sh/bun","slug":"required-argument-name-cannot-follow-an-optiona","errorCode":null,"errorMessage":"Required argument ${name} cannot follow an optional argument","messagePattern":"Required argument (.+?) cannot follow an optional argument","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/codegen/bindgen-lib-internal.ts","lineNumber":843,"sourceCode":"  return func;\n}\n\nfunction validateVariant(variant: any) {\n  let minRequiredArgs = 0;\n  let seenOptionalArgument = false;\n  let i = 0;\n\n  for (const [name, type] of Object.entries(variant.args) as [string, TypeImpl][]) {\n    if (!(type instanceof TypeImpl)) {\n      throw new Error(`Expected type for argument ${name}, got ${inspect(type)}`);\n    }\n    i += 1;\n    if (type.isVirtualArgument()) {\n      continue;\n    }\n    if (!type.flags.optional && !(\"default\" in type.flags)) {\n      if (seenOptionalArgument) {\n        throw new Error(`Required argument ${name} cannot follow an optional argument`);\n      }\n      minRequiredArgs++;\n    } else {\n      seenOptionalArgument = true;\n    }\n  }\n\n  return { minRequiredArgs };\n}\n\nfunction snapshotCallerLocation(): string {\n  const stack = new Error().stack!;\n  const lines = stack.split(\"\\n\");\n  let i = 1;\n  for (; i < lines.length; i++) {\n    if (!lines[i].includes(import.meta.dir)) {\n      return lines[i];\n    }","sourceCodeStart":825,"sourceCodeEnd":861,"githubUrl":"https://github.com/oven-sh/bun/blob/8c5296ac459e8252d3cd702f3fbcbb0c249d95d5/src/codegen/bindgen-lib-internal.ts#L825-L861","documentation":"Error \"Required argument ${name} cannot follow an optional argument\" thrown in oven-sh/bun.","triggerScenarios":"Thrown at src/codegen/bindgen-lib-internal.ts:843 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"}