{"record":{"id":"387f6f9bb2ecef56","repo":"tailwindlabs/tailwindcss","slug":"step-cannot-be-zero-in-sequence-expansion","errorCode":null,"errorMessage":"Step cannot be zero in sequence expansion.","messagePattern":"Step cannot be zero in sequence expansion\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/tailwindcss/src/utils/brace-expansion.ts","lineNumber":79,"sourceCode":" */\nfunction expandSequence(seq: string): string[] {\n  let seqMatch = seq.match(NUMERICAL_RANGE)\n  if (!seqMatch) {\n    return [seq]\n  }\n  let [, start, end, stepStr] = seqMatch\n  let step = stepStr ? parseInt(stepStr, 10) : undefined\n  let result: string[] = []\n\n  if (/^-?\\d+$/.test(start) && /^-?\\d+$/.test(end)) {\n    let startNum = parseInt(start, 10)\n    let endNum = parseInt(end, 10)\n\n    if (step === undefined) {\n      step = startNum <= endNum ? 1 : -1\n    }\n    if (step === 0) {\n      throw new Error('Step cannot be zero in sequence expansion.')\n    }\n\n    let increasing = startNum < endNum\n    if (increasing && step < 0) step = -step\n    if (!increasing && step > 0) step = -step\n\n    for (let i = startNum; increasing ? i <= endNum : i >= endNum; i += step) {\n      result.push(i.toString())\n    }\n  }\n  return result\n}\n","sourceCodeStart":61,"sourceCodeEnd":92,"githubUrl":"https://github.com/tailwindlabs/tailwindcss/blob/16e94cbf7f965c5ad697e90e940b5e178efad67c/packages/tailwindcss/src/utils/brace-expansion.ts#L61-L92","documentation":"Thrown by expandSequence() when a numeric range like '{1..10..step}' has an explicit step of 0. A zero step would produce an infinite loop, so it is rejected outright. The step comes from the third segment of the '..'-delimited sequence; when omitted it defaults to 1 or -1 based on direction.","triggerScenarios":"Passing a pattern like '{1..10..0}' or '{5..1..0}' to expand(). The NUMERICAL_RANGE regex at brace-expansion.ts:3 captures the optional third group, and parseInt yields 0.","commonSituations":"Computing a step value programmatically and passing 0 when a range is degenerate. Copying a range pattern and forgetting to set a real step. Off-by-one in dynamic step generation.","solutions":["Provide a non-zero step: '{1..10..1}' or '{1..10..2}'.","If the step is computed, clamp it to at least 1 (or -1) before forming the pattern.","Omit the step entirely to get the default of 1 (ascending) or -1 (descending)."],"exampleFix":"// before — throws\nexpand('{0..10..0}')\n\n// after\nexpand('{0..10..2}')","handlingStrategy":"validation","validationCode":"function safeSequence(start: number, end: number, step?: number): string {\n  const s = step === undefined ? (start <= end ? 1 : -1) : step\n  if (s === 0) throw new Error('step must be non-zero')\n  return `{${start}..${end}..${s}}`\n}","typeGuard":"function isValidStep(step: number): boolean {\n  return step !== 0\n}","tryCatchPattern":null,"preventionTips":["Clamp computed step values to abs >= 1.","Omit the step segment to use the safe default direction-aware step.","Validate the third segment of '..' sequences before forming the pattern."],"tags":["tailwindcss","brace-expansion","sequence","parsing"],"backgroundTag":null,"analyzedSha":"16e94cbf7f965c5ad697e90e940b5e178efad67c","analyzedAt":"2026-08-12T06:02:42.469Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}