From 05dc664f7d1ff62a850b122fbc83d62d7857687b Mon Sep 17 00:00:00 2001 From: Luke Sandberg Date: Thu, 1 Aug 2024 14:26:08 -0700 Subject: [PATCH] Fix a bug in toSourceString by ensuring that grouping parens are added when needed PiperOrigin-RevId: 658538818 --- java/src/com/google/template/soy/exprtree/DataAccessNode.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/java/src/com/google/template/soy/exprtree/DataAccessNode.java b/java/src/com/google/template/soy/exprtree/DataAccessNode.java index 68f6a50874..79364d6489 100644 --- a/java/src/com/google/template/soy/exprtree/DataAccessNode.java +++ b/java/src/com/google/template/soy/exprtree/DataAccessNode.java @@ -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(); } }