Skip to content

Commit

Permalink
Fix a bug in toSourceString by ensuring that grouping parens are adde…
Browse files Browse the repository at this point in the history
…d when needed

PiperOrigin-RevId: 658538818
  • Loading branch information
lukesandberg authored and copybara-github committed Sep 9, 2024
1 parent 7c2ec2c commit 05dc664
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions java/src/com/google/template/soy/exprtree/DataAccessNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ public final SourceLocation getAccessSourceLocation() {

@Override
public String toSourceString() {
if (SoyPrecedence.shouldGuard(this, getBaseExprChild())) {
return "(" + getBaseExprChild().toSourceString() + ")" + getSourceStringSuffix();
}
return getBaseExprChild().toSourceString() + getSourceStringSuffix();
}
}

0 comments on commit 05dc664

Please sign in to comment.