Bug 18671 - SquirrelFish: continue inside switch fails
Summary: SquirrelFish: continue inside switch fails
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: Macintosh OS X 10.5
: P2 Normal
Assignee: Cameron Zwarich (cpst)
URL:
Keywords: EasyFix
Depends on:
Blocks:
 
Reported: 2008-04-21 15:46 PDT by Oliver Hunt
Modified: 2008-04-21 17:51 PDT (History)
4 users (show)

See Also:


Attachments
Proposed patch (2.84 KB, patch)
2008-04-21 16:20 PDT, Cameron Zwarich (cpst)
oliver: review+
Details | Formatted Diff | Diff
Revised proposed patch (2.86 KB, patch)
2008-04-21 16:32 PDT, Cameron Zwarich (cpst)
oliver: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Oliver Hunt 2008-04-21 15:46:13 PDT
Valid continue statements fail inside a switch statement

while(1) {
   print("foo");
   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.