{"record":{"id":"37f1ab7e5648680d","repo":"oven-sh/bun","slug":"class-mismatch-at-u-cp-tostring-16","errorCode":null,"errorMessage":"class mismatch at U+${cp.toString(16)}","messagePattern":"class mismatch at U\\+(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"scripts/generate-stringwidth-tables.mjs","lineNumber":236,"sourceCode":"  }\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  }\n  return lines.join(\"\\n\");\n}\n\nconst output = `// clang-format off\n// Generated by scripts/generate-stringwidth-tables.mjs from the Unicode\n// ${UNICODE_VERSION} Character Database. Do not edit manually; regenerate with\n//   bun scripts/generate-stringwidth-tables.mjs","sourceCodeStart":218,"sourceCodeEnd":254,"githubUrl":"https://github.com/oven-sh/bun/blob/8c5296ac459e8252d3cd702f3fbcbb0c249d95d5/scripts/generate-stringwidth-tables.mjs#L218-L254","documentation":"Error \"class mismatch at U+${cp.toString(16)}\" thrown in oven-sh/bun.","triggerScenarios":"Thrown at scripts/generate-stringwidth-tables.mjs:236 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"}