Skip to content

Commit

Permalink
Fix a Parser Idempotency Issue
Browse files Browse the repository at this point in the history
This PR fixes boa-dev#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`.
  • Loading branch information
veera-sivarajan authored and raskad committed Dec 3, 2023
1 parent eb2f33e commit 1867f4b
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions boa_ast/src/statement/with.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -52,12 +52,12 @@ impl From<With> 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)
)
}
}
Expand Down

0 comments on commit 1867f4b

Please sign in to comment.