tailwindlabs/tailwindcss · error · Error

Step cannot be zero in sequence expansion.

Error message

Step cannot be zero in sequence expansion.

What it means

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.

Source

Thrown at packages/tailwindcss/src/utils/brace-expansion.ts:79

 */
function expandSequence(seq: string): string[] {
  let seqMatch = seq.match(NUMERICAL_RANGE)
  if (!seqMatch) {
    return [seq]
  }
  let [, start, end, stepStr] = seqMatch
  let step = stepStr ? parseInt(stepStr, 10) : undefined
  let result: string[] = []

  if (/^-?\d+$/.test(start) && /^-?\d+$/.test(end)) {
    let startNum = parseInt(start, 10)
    let endNum = parseInt(end, 10)

    if (step === undefined) {
      step = startNum <= endNum ? 1 : -1
    }
    if (step === 0) {
      throw new Error('Step cannot be zero in sequence expansion.')
    }

    let increasing = startNum < endNum
    if (increasing && step < 0) step = -step
    if (!increasing && step > 0) step = -step

    for (let i = startNum; increasing ? i <= endNum : i >= endNum; i += step) {
      result.push(i.toString())
    }
  }
  return result
}

View on GitHub (pinned to 16e94cbf7f)

Solutions

  1. Provide a non-zero step: '{1..10..1}' or '{1..10..2}'.
  2. If the step is computed, clamp it to at least 1 (or -1) before forming the pattern.
  3. Omit the step entirely to get the default of 1 (ascending) or -1 (descending).

Example fix

// before — throws
expand('{0..10..0}')

// after
expand('{0..10..2}')
Defensive patterns

Strategy: validation

Validate before calling

function safeSequence(start: number, end: number, step?: number): string {
  const s = step === undefined ? (start <= end ? 1 : -1) : step
  if (s === 0) throw new Error('step must be non-zero')
  return `{${start}..${end}..${s}}`
}

Type guard

function isValidStep(step: number): boolean {
  return step !== 0
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of tailwindlabs/tailwindcss@16e94cbf7f (2026-08-12). Data as JSON: /api/errors/387f6f9bb2ecef56. Report an issue: GitHub.