{"record":{"id":"3b11bf6be02d69b7","repo":"oven-sh/bun","slug":"stage1-offsets-no-longer-fit-in-uint16-t","errorCode":null,"errorMessage":"stage1 offsets no longer fit in uint16_t","messagePattern":"stage1 offsets no longer fit in uint16_t","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"scripts/generate-stringwidth-tables.mjs","lineNumber":229,"sourceCode":"    if (index === undefined) {\n      index = newStage3.length;\n      if (index > 255) throw new Error(\"more than 256 distinct packed values\");\n      valueToIndex.set(value, index);\n      newStage3.push(value);\n    }\n    block[low] = index;\n  }\n  const key = block.join(\",\");\n  let offset = blockKeyToOffset.get(key);\n  if (offset === undefined) {\n    offset = newStage2.length;\n    blockKeyToOffset.set(key, offset);\n    newStage2.push(...block);\n  }\n  newStage1[high] = offset;\n}\n\nif (newStage2.length - 256 > 0xffff) throw new Error(\"stage1 offsets no longer fit in uint16_t\");\n\n// Verify the rebuilt table roundtrips for every codepoint and preserves the\n// original grapheme classes exactly.\nfor (let cp = 0; cp <= 0x10ffff; cp++) {\n  const got = newStage3[newStage2[newStage1[cp >> 8] + (cp & 0xff)]];\n  if (got !== packed(cp)) throw new Error(`roundtrip mismatch at U+${cp.toString(16)}`);\n  if ((got & 0x1f) !== classOf(cp)) throw new Error(`class mismatch at U+${cp.toString(16)}`);\n}\n\n// ---------------------------------------------------------------------------\n// Emit\n// ---------------------------------------------------------------------------\n\nfunction formatArray(values, perLine) {\n  const lines = [];\n  for (let i = 0; i < values.length; i += perLine) {\n    lines.push(\"    \" + values.slice(i, i + perLine).join(\", \") + \",\");\n  }","sourceCodeStart":211,"sourceCodeEnd":247,"githubUrl":"https://github.com/oven-sh/bun/blob/8c5296ac459e8252d3cd702f3fbcbb0c249d95d5/scripts/generate-stringwidth-tables.mjs#L211-L247","documentation":"Error \"stage1 offsets no longer fit in uint16_t\" thrown in oven-sh/bun.","triggerScenarios":"Thrown at scripts/generate-stringwidth-tables.mjs:229 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"}