Bug 18671

Summary: SquirrelFish: continue inside switch fails
Product: WebKit Reporter: Oliver Hunt <oliver>
Component: JavaScriptCoreAssignee: Cameron Zwarich (cpst) <zwarich>
Severity: Normal CC: ggaren, mjs, oliver, zwarich
Priority: P2 Keywords: EasyFix
Version: 528+ (Nightly build)   
Hardware: Mac   
OS: OS X 10.5   
Description Flags
Proposed patch
oliver: review+
Revised proposed patch oliver: review+

Description Oliver Hunt 2008-04-21 15:46:13 PDT
Valid continue statements fail inside a switch statement

while(1) {
   switch(1) { case 1: continue; }

The problem is that getJumpContext with an empty label will return the nearest JumpContext, but in the case of continue it needs to return the nearest JumpContext with a continue target.
Comment 1 Cameron Zwarich (cpst) 2008-04-21 16:20:40 PDT
Created attachment 20741 [details]
Proposed patch

Here is a fix.
Comment 2 Oliver Hunt 2008-04-21 16:23:48 PDT
Comment on attachment 20741 [details]
Proposed patch

I'd prefer:
+        if (forContinue) {
+            for (int i = m_jumpContextStack.size() - 1; i >= 0; i--) {
+                JumpContext* scope = &m_jumpContextStack[i];
+                if (scope->continueTarget)
+                    return scope;                
+            }
+            return 0;
+       }

But other than that, r=me
Comment 3 Cameron Zwarich (cpst) 2008-04-21 16:32:04 PDT
Created attachment 20742 [details]
Revised proposed patch

Modified as per Oliver's suggestion.