diff --git a/HISTORY b/HISTORY index e040461..9a04127 100755 --- a/HISTORY +++ b/HISTORY @@ -1,5 +1,6 @@ Nov. 30 2015 Improved stability for sub routine +Improved error handling with shell Nov. 26 2015 Raised error for invalid routine usage diff --git a/core/my_basic.c b/core/my_basic.c index b8ded9c..79549ef 100755 --- a/core/my_basic.c +++ b/core/my_basic.c @@ -3620,16 +3620,9 @@ _end_import: goto _exit; } if(glbsyminscope && ((_object_t*)(glbsyminscope->data))->type == _DT_VAR) { - tmp.obj = (_object_t*)(glbsyminscope->data); - if(!tmp.obj->ref) { - _ht_remove(running->var_dict, sym, _ls_cmp_extra_string); - _dispose_object(tmp.obj); - } - tmp.obj->type = _DT_ROUTINE; - tmp.obj->data.routine = (_routine_t*)mb_malloc(sizeof(_routine_t)); - _init_routine(s, tmp.obj->data.routine, sym); - _push_scope(s, tmp.obj->data.routine->scope); - _ht_set_or_insert(running->var_dict, sym, tmp.obj); + _handle_error_now(s, SE_RN_INVALID_ROUTINE, 0, MB_FUNC_ERR); + + goto _exit; } if(_IS_FUNC(context->last_symbol, _core_def)) { diff --git a/output/my_basic.exe b/output/my_basic.exe index 37cbba4..52ad1dd 100755 Binary files a/output/my_basic.exe and b/output/my_basic.exe differ diff --git a/shell/main.c b/shell/main.c index d13e2d0..9d60afc 100755 --- a/shell/main.c +++ b/shell/main.c @@ -703,9 +703,14 @@ static int _do_line(void) { int i = 0; mb_assert(c); result = mb_reset(&bas, false); - for(i = 0; i < c->count; ++i) - mb_load_string(bas, c->lines[i]); - result = mb_run(bas); + for(i = 0; i < c->count; ++i) { + if(result) + break; + + result = mb_load_string(bas, c->lines[i]); + } + if(result == MB_FUNC_OK) + result = mb_run(bas); _printf("\n"); } else if(_str_eq(line, "BYE")) { result = MB_FUNC_BYE;