Mercurial > vim
diff 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 |
line wrap: on
line diff
--- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -4961,6 +4961,7 @@ compile_assignment(char_u *arg, exarg_T } if (need_type(stacktype, &t_list_any, -1, cctx, FALSE) == FAIL) goto theend; + // TODO: check the length of a constant list here generate_CHECKLEN(cctx, semicolon ? var_count - 1 : var_count, semicolon); } @@ -6539,6 +6540,7 @@ compile_finally(char_u *arg, cctx_T *cct // Previous catch without match jumps here isn = ((isn_T *)instr->ga_data) + scope->se_u.se_try.ts_catch_label; isn->isn_arg.jump.jump_where = instr->ga_len; + scope->se_u.se_try.ts_catch_label = 0; } // TODO: set index in ts_finally_label jumps @@ -6584,8 +6586,18 @@ compile_endtry(char_u *arg, cctx_T *cctx compile_fill_jump_to_end(&scope->se_u.se_try.ts_end_label, cctx); // End :catch or :finally scope: set value in ISN_TRY instruction + if (isn->isn_arg.try.try_catch == 0) + isn->isn_arg.try.try_catch = instr->ga_len; if (isn->isn_arg.try.try_finally == 0) isn->isn_arg.try.try_finally = instr->ga_len; + + if (scope->se_u.se_try.ts_catch_label != 0) + { + // Last catch without match jumps here + isn = ((isn_T *)instr->ga_data) + scope->se_u.se_try.ts_catch_label; + isn->isn_arg.jump.jump_where = instr->ga_len; + } + compile_endblock(cctx); if (generate_instr(cctx, ISN_ENDTRY) == NULL)