diff --git a/HISTORY b/HISTORY index 8091fb3..be5e82a 100755 --- a/HISTORY +++ b/HISTORY @@ -1,6 +1,7 @@ Jan. 25 2016 Fixed a memory leak when printing a referenced usertype Fixed a bug with nested IF statement +Fixed a bug with WHILE and DO statements when returning from a sub routine Fixed an indexing bug with list Added a new sample script source file diff --git a/core/my_basic.c b/core/my_basic.c index 6bb639e..1136440 100755 --- a/core/my_basic.c +++ b/core/my_basic.c @@ -12380,7 +12380,12 @@ _loop_begin: result = MB_FUNC_OK; goto _exit; - } else if(result != MB_FUNC_OK && result != MB_SUB_RETURN) { /* Normally */ + } else if(result == MB_SUB_RETURN) { /* RETURN */ + if(ast) ast = ast->prev; + if(ast) ast = ast->prev; + + goto _exit; + } else if(result != MB_FUNC_OK) { /* Normally */ goto _exit; } @@ -12454,7 +12459,12 @@ _loop_begin: result = MB_FUNC_OK; goto _exit; - } else if(result != MB_FUNC_OK && result != MB_SUB_RETURN) { /* Normally */ + } else if(result == MB_SUB_RETURN) { /* RETURN */ + if(ast) ast = ast->prev; + if(ast) ast = ast->prev; + + goto _exit; + } else if(result != MB_FUNC_OK) { /* Normally */ goto _exit; } diff --git a/output/my_basic.exe b/output/my_basic.exe index 1687d9d..c619591 100755 Binary files a/output/my_basic.exe and b/output/my_basic.exe differ