{"record":{"id":"e2841050b0d6da3b","repo":"oven-sh/bun","slug":"more-than-256-distinct-packed-values","errorCode":null,"errorMessage":"more than 256 distinct packed values","messagePattern":"more than 256 distinct packed values","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"scripts/generate-stringwidth-tables.mjs","lineNumber":213,"sourceCode":"// ---------------------------------------------------------------------------\n// Rebuild the 3-stage table over the packed values\n// ---------------------------------------------------------------------------\n\nconst highCount = stage1.length; // 8192 blocks of 256 codepoints\nconst blockKeyToOffset = new Map();\nconst newStage1 = new Array(highCount);\nconst newStage2 = [];\nconst valueToIndex = new Map();\nconst newStage3 = [];\n\nfor (let high = 0; high < highCount; high++) {\n  const block = new Array(256);\n  for (let low = 0; low < 256; low++) {\n    const value = packed(high * 256 + low);\n    let index = valueToIndex.get(value);\n    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","sourceCodeStart":195,"sourceCodeEnd":231,"githubUrl":"https://github.com/oven-sh/bun/blob/8c5296ac459e8252d3cd702f3fbcbb0c249d95d5/scripts/generate-stringwidth-tables.mjs#L195-L231","documentation":"Error \"more than 256 distinct packed values\" thrown in oven-sh/bun.","triggerScenarios":"Thrown at scripts/generate-stringwidth-tables.mjs:213 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"}