Stop warning about break at the end of 'default' in switch statement

This commit is contained in:
Gordon Williams 2014-06-16 10:52:30 +01:00
parent a0dee715d3
commit 8fa1c554e9
3 changed files with 12 additions and 0 deletions

View File

@ -14,6 +14,7 @@
Added throw and try..catch..finally (see #40)
Fixed overriding of builtins with other Builtins
Added Date.valueOf
Stop warning about break at the end of 'default' in switch statement
1v64 : Fix 'a=[2,3,4];delete a[1];'
Make sure parseInt("0x01",16)==1 and parseInt("0x01")==1 but parseInt("0b01",16)==0

View File

@ -1622,8 +1622,11 @@ NO_INLINE JsVar *jspeStatementSwitch() {
JSP_MATCH(':');
JSP_SAVE_EXECUTE();
if (hasExecuted) jspSetNoExecute();
else execInfo.execute |= EXEC_IN_SWITCH;
while (!JSP_SHOULDNT_PARSE && execInfo.lex->tk!=LEX_EOF && execInfo.lex->tk!='}')
jsvUnLock(jspeBlockOrStatement());
if (execute && !hasExecuted)
execInfo.execute = execInfo.execute & (JsExecFlags)~EXEC_BREAK;
JSP_RESTORE_EXECUTE();
}
JSP_MATCH('}');

View File

@ -0,0 +1,8 @@
// Espruino complains about breaks at the end of 'default' - it shouldn't
switch(2){
case 1:break;
default:break;
}
result = 1;