diff --git a/HISTORY b/HISTORY index 2f582c9..5ffe3c6 100755 --- a/HISTORY +++ b/HISTORY @@ -1,5 +1,8 @@ +Jun. 28 2021 +Improved error prompting of assigning to reserved word + Apr. 9 2020 -Improved incomplete IF structure error prompting +Improved error prompting of incomplete IF structure Mar. 16 2019 Fixed a memory leak when reassigning an array element with string, thanks to Jacques Diederik for pointing it out diff --git a/core/my_basic.c b/core/my_basic.c index 47450b5..4b10028 100755 --- a/core/my_basic.c +++ b/core/my_basic.c @@ -271,6 +271,7 @@ MBCONST static const char* const _ERR_DESC[] = { "Too many dimensions", "Rank out of bound", "Invalid identifier usage", + "Cannot assign to reserved word", "Duplicate identifier", "Incomplete structure", "Label not exists", @@ -15426,7 +15427,7 @@ static int _core_let(mb_interpreter_t* s, void** l) { goto _exit; } else if(obj->type == _DT_VAR) { if(_IS_ME(obj->data.variable)) { - _handle_error_on_obj(s, SE_RN_INVALID_ID_USAGE, s->source_file, DON(ast), MB_FUNC_ERR, _exit, result); + _handle_error_on_obj(s, SE_RN_CANNOT_ASSIGN_TO_RESERVED_WORD, s->source_file, DON(ast), MB_FUNC_ERR, _exit, result); } else { evar = obj->data.variable; var = _search_var_in_scope_chain(s, obj->data.variable, 0); @@ -15435,11 +15436,11 @@ static int _core_let(mb_interpreter_t* s, void** l) { if(evar && evar->pathing == _PATHING_UPVALUE) evar = 0; #endif /* MB_ENABLE_CLASS */ if(var == _OBJ_BOOL_TRUE->data.variable || var == _OBJ_BOOL_FALSE->data.variable) { - _handle_error_on_obj(s, SE_RN_INVALID_ID_USAGE, s->source_file, DON(ast), MB_FUNC_ERR, _exit, result); + _handle_error_on_obj(s, SE_RN_CANNOT_ASSIGN_TO_RESERVED_WORD, s->source_file, DON(ast), MB_FUNC_ERR, _exit, result); } } } else { - _handle_error_on_obj(s, SE_RN_INVALID_ID_USAGE, s->source_file, DON(ast), MB_FUNC_ERR, _exit, result); + _handle_error_on_obj(s, SE_RN_CANNOT_ASSIGN_TO_RESERVED_WORD, s->source_file, DON(ast), MB_FUNC_ERR, _exit, result); } ast = ast->next; diff --git a/core/my_basic.h b/core/my_basic.h index 8c6eb75..c63c45b 100755 --- a/core/my_basic.h +++ b/core/my_basic.h @@ -425,6 +425,7 @@ typedef enum mb_error_e { SE_RN_TOO_MANY_DIMENSIONS, SE_RN_RANK_OUT_OF_BOUND, SE_RN_INVALID_ID_USAGE, + SE_RN_CANNOT_ASSIGN_TO_RESERVED_WORD, SE_RN_DUPLICATE_ID, SE_RN_INCOMPLETE_STRUCTURE, SE_RN_LABEL_NOT_EXISTS,