if (s) RETURN_STATUS(s);
t = p->lex;
- if (t == XC_LEX_NLINE || t == BC_LEX_SCOLON)
+ if (t == XC_LEX_NLINE || t == BC_LEX_SCOLON || t == BC_LEX_RBRACE)
xc_parse_push(BC_INST_RET0);
else {
- bool paren = (t == BC_LEX_LPAREN);
- s = bc_parse_expr_empty_ok(0);
- if (s == BC_STATUS_PARSE_EMPTY_EXP) {
- xc_parse_push(BC_INST_RET0);
- s = zxc_lex_next();
- }
+ s = zbc_parse_expr(0);
if (s) RETURN_STATUS(s);
- if (!paren || p->lex_last != BC_LEX_RPAREN) {
+ if (t != BC_LEX_LPAREN // "return EXPR", no ()
+ || p->lex_last != BC_LEX_RPAREN // example: "return (a) + b"
+ ) {
s = zbc_POSIX_requires("parentheses around return expressions");
if (s) RETURN_STATUS(s);
}
"2\n9\n" \
"" "for (;;) {2;break}; 9"
+testing "bc define {return}" \
+ "bc" \
+ "0\n9\n" \
+ "" "define w() {return}\nw();9"
+
testing "bc define auto" \
"bc" \
"8\n9\n" \