Mercurial > vim
comparison src/testdir/test_vim9_script.vim @ 21359:e3711ce8133b v8.2.1230
patch 8.2.1230: Vim9: list index error not caught by try/catch
Commit: https://github.com/vim/vim/commit/68d130c618f363821761f231c4122a0b9b764b71
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Jul 17 22:06:44 2020 +0200
patch 8.2.1230: Vim9: list index error not caught by try/catch
Problem: Vim9: list index error not caught by try/catch.
Solution: Do not bail out if an error is inside try/catch. (closes https://github.com/vim/vim/issues/6462)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 17 Jul 2020 22:15:04 +0200 |
parents | fb8c8fcb7b60 |
children | fca850f4d603 |
comparison
equal
deleted
inserted
replaced
21358:36a728847328 | 21359:e3711ce8133b |
---|---|
507 add(l, v:exception) | 507 add(l, v:exception) |
508 finally # comment | 508 finally # comment |
509 add(l, '3') | 509 add(l, '3') |
510 endtry # comment | 510 endtry # comment |
511 assert_equal(['1', 'wrong', '3'], l) | 511 assert_equal(['1', 'wrong', '3'], l) |
512 | |
513 let n: number | |
514 try | |
515 n = l[3] | |
516 catch /E684:/ | |
517 n = 99 | |
518 endtry | |
519 assert_equal(99, n) | |
520 | |
521 try | |
522 n = g:astring[3] | |
523 catch /E714:/ | |
524 n = 77 | |
525 endtry | |
526 assert_equal(77, n) | |
527 | |
528 try | |
529 n = l[g:astring] | |
530 catch /E39:/ | |
531 n = 77 | |
532 endtry | |
533 assert_equal(77, n) | |
534 | |
535 try | |
536 n = s:does_not_exist | |
537 catch /E121:/ | |
538 n = 121 | |
539 endtry | |
540 assert_equal(121, n) | |
541 | |
542 let d = #{one: 1} | |
543 try | |
544 n = d[g:astring] | |
545 catch /E716:/ | |
546 n = 222 | |
547 endtry | |
548 assert_equal(222, n) | |
512 enddef | 549 enddef |
513 | 550 |
514 def ThrowFromDef() | 551 def ThrowFromDef() |
515 throw "getout" # comment | 552 throw "getout" # comment |
516 enddef | 553 enddef |