From 46abeec2b87ff92a926c1014df8590e906e68de0 Mon Sep 17 00:00:00 2001 From: Evan Shaw Date: Wed, 21 Sep 2022 22:22:21 +1200 Subject: [PATCH] Add precedence for shorthand ternary operator --- trunk_parser/src/parser/mod.rs | 13 +++++++++++++ trunk_parser/src/parser/precedence.rs | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/trunk_parser/src/parser/mod.rs b/trunk_parser/src/parser/mod.rs index 4e52272..db7b173 100644 --- a/trunk_parser/src/parser/mod.rs +++ b/trunk_parser/src/parser/mod.rs @@ -2783,6 +2783,19 @@ mod tests { r#else: Box::new(Expression::Int { i: 5 }), })], ); + + assert_ast( + " Self::And, BooleanOr => Self::Or, Coalesce => Self::NullCoalesce, - Question => Self::Ternary, + Question | QuestionColon => Self::Ternary, Equals | PlusEquals | MinusEquals | AsteriskEqual | PowEquals | SlashEquals | DotEquals | AndEqual | CoalesceEqual | PercentEquals | AmpersandEquals | PipeEquals | CaretEquals | LeftShiftEquals | RightShiftEquals => Self::Assignment,