1951: Lower the precedence of the `as` operator. r=matklad a=goffrie
Previously, the `as` operator was being parsed like a postfix expression, and
therefore being given the highest possible precedence. That caused it to bind
more tightly than prefix operators, which it should not. Instead, parse it
somewhat like a normal binary expression with some special-casing.
Fixes #1851.
Co-authored-by: Geoffry Song <goffrie@gmail.com>
// }
//
let (lhs, blocklike) = atom::atom_expr(p, r)?;
- return Some(postfix_expr(p, lhs, blocklike, !(r.prefer_stmt && blocklike.is_block())));
+ return Some(postfix_expr(
+ p,
+ lhs,
+ blocklike,
+ !(r.prefer_stmt && blocklike.is_block()),
+ r.forbid_structs,
+ ));
}
};
+ // parse the interior of the unary expression
expr_bp(p, r, 255);
Some((m.complete(p, kind), BlockLike::NotBlock))
}