Skip to content
9 changes: 6 additions & 3 deletions src/parser/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -933,7 +933,7 @@ pub struct Query {

impl fmt::Display for Query {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}{}", self.target, self.path)
write!(f, "{}.{}", self.target, self.path)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without this variable queries end up mushed together e.g. foo.bar becomes foobar however that then causes .foo.bar to become ..foo.bar without the change to QueryTarget below.

}
}

Expand All @@ -958,7 +958,7 @@ impl fmt::Display for QueryTarget {
match self {
Internal(v) => v.fmt(f),
External(prefix) => match prefix {
PathPrefix::Event => write!(f, "."),
PathPrefix::Event => write!(f, ""),
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably just remove this write! all together? If I understand correctly, and based on my testing QueryTarget always appears with a . after it even if OwnedValuePath is empty. So this is safe.

PathPrefix::Metadata => write!(f, "&"),
},
FunctionCall(v) => v.fmt(f),
Expand Down Expand Up @@ -1002,6 +1002,9 @@ pub struct FunctionCall {
impl fmt::Display for FunctionCall {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.ident.fmt(f)?;
if self.abort_on_error {
f.write_str("!")?;
}
f.write_str("(")?;

let mut iter = self.arguments.iter().peekable();
Expand Down Expand Up @@ -1196,7 +1199,7 @@ impl fmt::Display for Abort {
&self
.message
.as_ref()
.map_or_else(|| "abort".to_owned(), |m| format!("abort: {m}")),
.map_or_else(|| "abort".to_owned(), |m| format!("abort {m}")),
)
}
}
Expand Down