From 1867f4bac64016adaf616e8dc8f8166e026d7ea0 Mon Sep 17 00:00:00 2001 From: Veera Date: Tue, 25 Jul 2023 10:32:01 -0500 Subject: [PATCH] Fix a Parser Idempotency Issue This PR fixes #3133 by correctly implementing `ToIndentedString` for `with` statement. It also replaces the existing `ToInternedString` implementation because it is implemented for all types implementing `ToIndentedString` in `boa_interner/src/lib.rs`. --- boa_ast/src/statement/with.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/boa_ast/src/statement/with.rs b/boa_ast/src/statement/with.rs index 82b969099b3..4aad4e2659e 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) ) } }