Merge pull request #111 from edsrzf/shorthand-ternary-precedence

This commit is contained in:
Ryan Chandler 2022-09-21 13:00:21 +01:00 committed by GitHub
commit 54d0901a84
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View File

@ -2783,6 +2783,19 @@ mod tests {
r#else: Box::new(Expression::Int { i: 5 }),
})],
);
assert_ast(
"<?php 1 ?: 2 ?: 3;",
&[expr!(Expression::Ternary {
condition: Box::new(Expression::Int { i: 1 }),
then: None,
r#else: Box::new(Expression::Ternary {
condition: Box::new(Expression::Int { i: 2 }),
then: None,
r#else: Box::new(Expression::Int { i: 3 })
}),
})],
);
}
#[test]

View File

@ -64,7 +64,7 @@ impl Precedence {
BooleanAnd => 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,