parent
5faa925aea
commit
0afc3aba13
14
CHANGELOG.md
14
CHANGELOG.md
|
@ -1,5 +1,19 @@
|
|||
# Changelog
|
||||
|
||||
## v1.0.8-alpha - unreleased
|
||||
|
||||
### Added
|
||||
|
||||
N/A
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed operator precedences, in particular the pipe operator (`|>`) which is now of the lowest precedence.
|
||||
|
||||
### Removed
|
||||
|
||||
N/A
|
||||
|
||||
## v1.0.7-alpha - 2023-06-02
|
||||
|
||||
### Added
|
||||
|
|
|
@ -771,15 +771,15 @@ impl BinOp {
|
|||
pub fn precedence(&self) -> u8 {
|
||||
// Ensure that this matches the other precedence function for guards
|
||||
match self {
|
||||
Self::Or => 1,
|
||||
// Pipe is 0
|
||||
// Unary operators are 1
|
||||
Self::Or => 2,
|
||||
|
||||
Self::And => 2,
|
||||
Self::And => 3,
|
||||
|
||||
Self::Eq | Self::NotEq => 3,
|
||||
Self::Eq | Self::NotEq | Self::LtInt | Self::LtEqInt | Self::GtEqInt | Self::GtInt => 4,
|
||||
|
||||
Self::LtInt | Self::LtEqInt | Self::GtEqInt | Self::GtInt => 4,
|
||||
|
||||
// Pipe is 5
|
||||
// Concatenation operators are typically 5, so we skip it.
|
||||
Self::AddInt | Self::SubInt => 6,
|
||||
|
||||
Self::MultInt | Self::DivInt | Self::ModInt => 7,
|
||||
|
|
|
@ -651,7 +651,7 @@ impl UntypedExpr {
|
|||
pub fn binop_precedence(&self) -> u8 {
|
||||
match self {
|
||||
Self::BinOp { name, .. } => name.precedence(),
|
||||
Self::PipeLine { .. } => 5,
|
||||
Self::PipeLine { .. } => 0,
|
||||
_ => std::u8::MAX,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -799,3 +799,20 @@ fn test_fail() {
|
|||
|
||||
assert_fmt(src, src);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pipes_and_expressions() {
|
||||
let src = indoc! {r#"
|
||||
test fmt() {
|
||||
(x == y) && ((z |> length()) == x)
|
||||
}
|
||||
"#};
|
||||
|
||||
let expected = indoc! {r#"
|
||||
test fmt() {
|
||||
x == y && ( z |> length() ) == x
|
||||
}
|
||||
"#};
|
||||
|
||||
assert_fmt(src, expected);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue