Skip to content

Commit 7978b05

Browse files
committed
err on missing rhs to unary operator within subexpr
1 parent e1cf81f commit 7978b05

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

parse.go

+3
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,9 @@ func parselhs(scan *lexer, p *parsectx, until operator) (*node, error) {
409409
if err != nil {
410410
return nil, err
411411
}
412+
if rhs == nil {
413+
return nil, &EmptyExpressionError{Col: tok.pos, End: scan.must().text}
414+
}
412415
n = &node{kind: prec.op, left: rhs}
413416
case tokenOpen:
414417
match := rightbracket(tok.text)

parse_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,7 @@ func TestParseErrors(t *testing.T) {
434434

435435
// Cases identified with fuzzing.
436436
{"op-paren", "(b*)", new(EmptyExpressionError), []string{`\)`}, nil},
437+
{"haskell", "(+)", new(EmptyExpressionError), []string{`\)`}, nil},
437438
}
438439
preset := ParsingPreset(DisableDefaultFuncs(), ParseFuncs(testfns))
439440
for _, c := range cases {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
go test fuzz v1
2+
string("(+)")

0 commit comments

Comments
 (0)