harec

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 5bed9c64bbf2e52bb8c79a172a2a561eac018020
parent e3a33bc41c7f0200a85ad34ab21ea2b1013dba1b
Author: Sebastian <sebastian@sebsite.pw>
Date:   Wed,  2 Mar 2022 23:02:10 -0500

parse: allow switch/match/compound to start bin/cast expr

Minimal reproduction of bug:

$ cat > t.ha <<'EOF'
use os;

export fn main() void = {
	os::exit({
		yield 1;
	} - 0);
};
EOF
$ hare build t.ha
Syntax error: unexpected '-' at /tmp/t.ha:6:11, expected ',', ')'
Error: harec: exited with status 1
hare build: build failed

Signed-off-by: Sebastian <sebastian@sebsite.pw>

Diffstat:
Msrc/parse.c | 6++++++
1 file changed, 6 insertions(+), 0 deletions(-)

diff --git a/src/parse.c b/src/parse.c @@ -2183,12 +2183,18 @@ parse_expression(struct lexer *lexer) case T_LABEL: unlex(lexer, &tok); value = parse_compound_expression(lexer); + value = parse_cast_expression(lexer, value); + value = parse_bin_expression(lexer, value, 0); break; case T_MATCH: value = parse_match_expression(lexer); + value = parse_cast_expression(lexer, value); + value = parse_bin_expression(lexer, value, 0); break; case T_SWITCH: value = parse_switch_expression(lexer); + value = parse_cast_expression(lexer, value); + value = parse_bin_expression(lexer, value, 0); break; default: assert(0);