gohugoio/hugo · error

'increment' must be < 0

Error message

'increment' must be < 0

What it means

Thrown by Seq in the 3-argument form when first > last but the increment is positive (line 466). The mirror of error 110: a positive step cannot descend from a higher first to a lower last, so the call is contradictory.

Source

Thrown at tpl/collections/collections.go:467

			first = -1
			inc = -1
		}
	} else if len(intArgs) == 2 {
		last = intArgs[1]
		if last < first {
			inc = -1
		}
	} else {
		inc = intArgs[1]
		last = intArgs[2]
		if inc == 0 {
			return nil, errors.New("'increment' must not be 0")
		}
		if first < last && inc < 0 {
			return nil, errors.New("'increment' must be > 0")
		}
		if first > last && inc > 0 {
			return nil, errors.New("'increment' must be < 0")
		}
	}

	// sanity check
	if last < -maxSeqSize {
		return nil, errSeqSizeExceedsLimit
	}
	size := ((last - first) / inc) + 1

	// sanity check
	if size <= 0 || size > maxSeqSize {
		return nil, errSeqSizeExceedsLimit
	}

	seq := make([]int, size)
	val := first
	for i := 0; ; i++ {
		seq[i] = val

View on GitHub (pinned to 52c9bd7908)

Solutions

  1. Use a negative step to descend: {{ seq 10 -1 1 }}.
  2. If ascending is intended, ensure first <= last ({{ seq 1 1 10 }}).
  3. Re-confirm argument order: start, increment, end.

Example fix

// before
{{ seq 10 1 1 }}
// after
{{ seq 10 -1 1 }}
Defensive patterns

Strategy: validation

Validate before calling

{{/* descending: negative step */}}
{{ seq 10 -1 1 }}

Prevention

When it happens

Trigger: Calling {{ seq 10 1 1 }} (start 10, end 1, but step +1); intending a descending range but forgetting the negative step; argument-order confusion.

Common situations: Building a countdown without a negative step; reusing an ascending seq snippet in a descending context; swapping start/end in a refactor.

Related errors


AI-assisted analysis of gohugoio/hugo@52c9bd7908 (2026-08-09). Data as JSON: /api/errors/a90fff792ea041d1. Report an issue: GitHub.