scrhartley commented on code in PR #106:
URL: https://github.com/apache/freemarker/pull/106#discussion_r1488379515


##########
freemarker-core/src/main/javacc/freemarker/core/FTL.jj:
##########
@@ -3892,18 +3895,50 @@ SwitchBlock Switch() :
     }
     [
            (
-               caseIns = Case()
-               {
-                   if (caseIns.condition == null) {
-                       if (defaultFound) {
-                           throw new ParseException(
-                           "You can only have one default case in a switch 
statement", template, start);
-                       }
-                       defaultFound = true;
-                   }
-                   switchBlock.addCase(caseIns);
-               }
-           )+
+            (
+                caseIns = Case()
+                {
+                    if (caseIns.condition == null) {
+                        if (defaultFound) {
+                            throw new ParseException(
+                            "You can only have one default case in a switch 
statement", template, start);
+                        }
+                        defaultFound = true;
+                    }
+                    switchBlock.addCase(caseIns);
+                }
+            )+
+            |
+            (
+                {
+                    // A Switch with Case supports break, but not one with On.
+                    // Do it this way to ensure backwards compatibility.
+                    breakableDirectiveNesting--;

Review Comment:
   A few lines up, at the SwitchBlock level, there's an increment. As soon as 
we notice we're in the `on` case, then we undo the increment. If there was a 
nested switch-case then it would be incremented again. This counter is only 
used at parse time to determine if we're in a context where `break` is allowed. 
Because `on` doesn't allow a closing tag, I don't think there's a possibility 
for a disallowed break to accidentally be allowed between `on` tags.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@freemarker.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to