diff --git a/boa_ast/src/statement/with.rs b/boa_ast/src/statement/with.rs index 82b969099b..4aad4e2659 100644 --- a/boa_ast/src/statement/with.rs +++ b/boa_ast/src/statement/with.rs @@ -4,7 +4,7 @@ use crate::{ try_break, visitor::{VisitWith, Visitor, VisitorMut}, }; -use boa_interner::{Interner, ToInternedString}; +use boa_interner::{Interner, ToIndentedString, ToInternedString}; use core::ops::ControlFlow; /// The `with` statement extends the scope chain for a statement. @@ -52,12 +52,12 @@ impl From for Statement { } } -impl ToInternedString for With { - fn to_interned_string(&self, interner: &Interner) -> String { +impl ToIndentedString for With { + fn to_indented_string(&self, interner: &Interner, indentation: usize) -> String { format!( - "with ({}) {{{}}}", - self.expression.to_interned_string(interner), - self.statement.to_interned_string(interner) + "with ({}) {}", + self.expression().to_interned_string(interner), + self.statement().to_indented_string(interner, indentation) ) } } diff --git a/boa_parser/src/parser/tests/format/statement.rs b/boa_parser/src/parser/tests/format/statement.rs index 8e5ff43c5b..4854e2a041 100644 --- a/boa_parser/src/parser/tests/format/statement.rs +++ b/boa_parser/src/parser/tests/format/statement.rs @@ -122,3 +122,15 @@ fn switch() { "#, ); } + +#[test] +fn with() { + test_formatting( + r#" + with (this) { + { + } + } + "#, + ); +}