zoekt icon indicating copy to clipboard operation
zoekt copied to clipboard

Errors for queries with imbalanced parentheses are reported only for too many left parentheses

Open isker opened this issue 1 year ago • 1 comments

Here are some input query strings and the results of parsing them, including the error, if any. Some of them should result in parse errors but do not.

( -> <nil> (query: missing close paren, got token <nil>)
(( -> <nil> (error parsing regexp: missing closing ): `((`)
((( -> <nil> (error parsing regexp: missing closing ): `(((`)
() -> TRUE (<nil>)
) -> TRUE (<nil>) # should error
)) -> TRUE (<nil>) # should error
))) -> TRUE (<nil>) # should error
foo -> substr:"foo" (<nil>)
foo) -> substr:"foo" (<nil>) # should error
foo)) -> substr:"foo" (<nil>) # should error
foo))) -> substr:"foo" (<nil>) # should error
(foo -> <nil> (error parsing regexp: missing closing ): `(foo`)
((foo -> <nil> (error parsing regexp: missing closing ): `((foo`)
(((foo -> <nil> (error parsing regexp: missing closing ): `(((foo`)
(foo) -> substr:"foo" (<nil>)
(foo)) -> substr:"foo" (<nil>) # should error
((foo)) -> substr:"foo" (<nil>)
(((foo)) -> <nil> (error parsing regexp: missing closing ): `(((foo))`)

isker avatar Feb 25 '23 21:02 isker

I took a quick look at this and have a potential solution at https://github.com/sourcegraph/zoekt/pull/569. However, I don't fully understand the nitty gritty of the parse functions so needs more testing/review before taking further.

keegancsmith avatar Mar 27 '23 15:03 keegancsmith