diff --git a/promql/parser/ast.go b/promql/parser/ast.go index 6496095287..49608a1322 100644 --- a/promql/parser/ast.go +++ b/promql/parser/ast.go @@ -487,7 +487,7 @@ func (e *BinaryExpr) PositionRange() posrange.PositionRange { } func (e *DurationExpr) PositionRange() posrange.PositionRange { - if e.Op == STEP || e.Op == RANGE { + if e.RHS == nil && e.LHS == nil { return posrange.PositionRange{ Start: e.StartPos, End: e.EndPos, @@ -496,7 +496,7 @@ func (e *DurationExpr) PositionRange() posrange.PositionRange { if e.RHS == nil { return posrange.PositionRange{ Start: e.StartPos, - End: e.RHS.PositionRange().End, + End: e.LHS.PositionRange().End, } } if e.LHS == nil {