diff --git a/promql/bench_test.go b/promql/bench_test.go index 661faa6556..98b51f5f79 100644 --- a/promql/bench_test.go +++ b/promql/bench_test.go @@ -664,6 +664,7 @@ func BenchmarkParser(b *testing.B) { `foo{a="b", foo!="bar", test=~"test", bar!~"baz"}`, `min_over_time(rate(foo{bar="baz"}[2s])[5m:])[4m:3s]`, "sum without(and, by, avg, count, alert, annotations)(some_metric) [30m:10s]", + `sort_by_label(metric, "foo", "bar")`, } errCases := []string{ "(", diff --git a/promql/parser/parse.go b/promql/parser/parse.go index 3a76ddb44d..d7f3b93994 100644 --- a/promql/parser/parse.go +++ b/promql/parser/parse.go @@ -819,7 +819,9 @@ func (p *parser) checkAST(node Node) (typ ValueType) { } i = len(n.Func.ArgTypes) - 1 } - p.expectType(arg, n.Func.ArgTypes[i], fmt.Sprintf("call to function %q", n.Func.Name)) + if t := p.checkAST(arg); t != n.Func.ArgTypes[i] { + p.addParseErrf(arg.PositionRange(), "expected type %s in call to function %q, got %s", DocumentedType(n.Func.ArgTypes[i]), n.Func.Name, DocumentedType(t)) + } } case *ParenExpr: