comparison src/vim9compile.c @ 21371:8e1081ede3b8 v8.2.1236

patch 8.2.1236: Vim9: a few errors not caught by try/catch Commit: https://github.com/vim/vim/commit/e859312e748297bde67a053fd3c486fc2c14b532 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Jul 18 15:17:02 2020 +0200 patch 8.2.1236: Vim9: a few errors not caught by try/catch Problem: Vim9: a few errors not caught by try/catch. Solution: Do not bail out if an error is inside try/catch. Fix that a not matching catch doesn't jump to :endtry.
author Bram Moolenaar <Bram@vim.org>
date Sat, 18 Jul 2020 15:30:03 +0200
parents fb8c8fcb7b60
children f25d007f90ac
comparison
equal deleted inserted replaced
21370:a652dd15819a 21371:8e1081ede3b8
4959 emsg(_(e_cannot_use_void)); 4959 emsg(_(e_cannot_use_void));
4960 goto theend; 4960 goto theend;
4961 } 4961 }
4962 if (need_type(stacktype, &t_list_any, -1, cctx, FALSE) == FAIL) 4962 if (need_type(stacktype, &t_list_any, -1, cctx, FALSE) == FAIL)
4963 goto theend; 4963 goto theend;
4964 // TODO: check the length of a constant list here
4964 generate_CHECKLEN(cctx, semicolon ? var_count - 1 : var_count, 4965 generate_CHECKLEN(cctx, semicolon ? var_count - 1 : var_count,
4965 semicolon); 4966 semicolon);
4966 } 4967 }
4967 } 4968 }
4968 4969
6537 if (scope->se_u.se_try.ts_catch_label != 0) 6538 if (scope->se_u.se_try.ts_catch_label != 0)
6538 { 6539 {
6539 // Previous catch without match jumps here 6540 // Previous catch without match jumps here
6540 isn = ((isn_T *)instr->ga_data) + scope->se_u.se_try.ts_catch_label; 6541 isn = ((isn_T *)instr->ga_data) + scope->se_u.se_try.ts_catch_label;
6541 isn->isn_arg.jump.jump_where = instr->ga_len; 6542 isn->isn_arg.jump.jump_where = instr->ga_len;
6543 scope->se_u.se_try.ts_catch_label = 0;
6542 } 6544 }
6543 6545
6544 // TODO: set index in ts_finally_label jumps 6546 // TODO: set index in ts_finally_label jumps
6545 6547
6546 return arg; 6548 return arg;
6582 // Fill in the "end" label in jumps at the end of the blocks, if not done 6584 // Fill in the "end" label in jumps at the end of the blocks, if not done
6583 // by ":finally". 6585 // by ":finally".
6584 compile_fill_jump_to_end(&scope->se_u.se_try.ts_end_label, cctx); 6586 compile_fill_jump_to_end(&scope->se_u.se_try.ts_end_label, cctx);
6585 6587
6586 // End :catch or :finally scope: set value in ISN_TRY instruction 6588 // End :catch or :finally scope: set value in ISN_TRY instruction
6589 if (isn->isn_arg.try.try_catch == 0)
6590 isn->isn_arg.try.try_catch = instr->ga_len;
6587 if (isn->isn_arg.try.try_finally == 0) 6591 if (isn->isn_arg.try.try_finally == 0)
6588 isn->isn_arg.try.try_finally = instr->ga_len; 6592 isn->isn_arg.try.try_finally = instr->ga_len;
6593
6594 if (scope->se_u.se_try.ts_catch_label != 0)
6595 {
6596 // Last catch without match jumps here
6597 isn = ((isn_T *)instr->ga_data) + scope->se_u.se_try.ts_catch_label;
6598 isn->isn_arg.jump.jump_where = instr->ga_len;
6599 }
6600
6589 compile_endblock(cctx); 6601 compile_endblock(cctx);
6590 6602
6591 if (generate_instr(cctx, ISN_ENDTRY) == NULL) 6603 if (generate_instr(cctx, ISN_ENDTRY) == NULL)
6592 return NULL; 6604 return NULL;
6593 return arg; 6605 return arg;