Mercurial > vim
comparison src/vim9compile.c @ 19530:48e71f948360 v8.2.0322
patch 8.2.0322: Vim9: error checks not tested
Commit: https://github.com/vim/vim/commit/b35efa5ed040162f5c988c71dfc1159045e47585
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Feb 26 20:15:18 2020 +0100
patch 8.2.0322: Vim9: error checks not tested
Problem: Vim9: error checks not tested.
Solution: Add more test cases. Avoid error for function loaded later.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 26 Feb 2020 20:30:09 +0100 |
parents | 3b026343f398 |
children | 8eeec8886c02 |
comparison
equal
deleted
inserted
replaced
19529:6f350fb85612 | 19530:48e71f948360 |
---|---|
1543 static int | 1543 static int |
1544 compile_load_scriptvar( | 1544 compile_load_scriptvar( |
1545 cctx_T *cctx, | 1545 cctx_T *cctx, |
1546 char_u *name, // variable NUL terminated | 1546 char_u *name, // variable NUL terminated |
1547 char_u *start, // start of variable | 1547 char_u *start, // start of variable |
1548 char_u **end) // end of variable | 1548 char_u **end, // end of variable |
1549 int error) // when TRUE may give error | |
1549 { | 1550 { |
1550 scriptitem_T *si = SCRIPT_ITEM(current_sctx.sc_sid); | 1551 scriptitem_T *si = SCRIPT_ITEM(current_sctx.sc_sid); |
1551 int idx = get_script_item_idx(current_sctx.sc_sid, name, FALSE); | 1552 int idx = get_script_item_idx(current_sctx.sc_sid, name, FALSE); |
1552 imported_T *import; | 1553 imported_T *import; |
1553 | 1554 |
1604 import->imp_type); | 1605 import->imp_type); |
1605 } | 1606 } |
1606 return OK; | 1607 return OK; |
1607 } | 1608 } |
1608 | 1609 |
1609 semsg(_("E1050: Item not found: %s"), name); | 1610 if (error) |
1611 semsg(_("E1050: Item not found: %s"), name); | |
1610 return FAIL; | 1612 return FAIL; |
1611 } | 1613 } |
1612 | 1614 |
1613 /* | 1615 /* |
1614 * Compile a variable name into a load instruction. | 1616 * Compile a variable name into a load instruction. |
1640 // exists, give error at runtime. | 1642 // exists, give error at runtime. |
1641 res = generate_LOAD(cctx, ISN_LOADG, 0, name, &t_any); | 1643 res = generate_LOAD(cctx, ISN_LOADG, 0, name, &t_any); |
1642 } | 1644 } |
1643 else if (**arg == 's') | 1645 else if (**arg == 's') |
1644 { | 1646 { |
1645 res = compile_load_scriptvar(cctx, name, NULL, NULL); | 1647 res = compile_load_scriptvar(cctx, name, NULL, NULL, error); |
1646 } | 1648 } |
1647 else | 1649 else |
1648 { | 1650 { |
1649 semsg("Namespace not supported yet: %s", **arg); | 1651 semsg("Namespace not supported yet: %s", **arg); |
1650 goto theend; | 1652 goto theend; |
1696 res = generate_PUSHBOOL(cctx, **arg == 't' | 1698 res = generate_PUSHBOOL(cctx, **arg == 't' |
1697 ? VVAL_TRUE : VVAL_FALSE); | 1699 ? VVAL_TRUE : VVAL_FALSE); |
1698 else if (SCRIPT_ITEM(current_sctx.sc_sid)->sn_version | 1700 else if (SCRIPT_ITEM(current_sctx.sc_sid)->sn_version |
1699 == SCRIPT_VERSION_VIM9) | 1701 == SCRIPT_VERSION_VIM9) |
1700 // in Vim9 script "var" can be script-local. | 1702 // in Vim9 script "var" can be script-local. |
1701 res = compile_load_scriptvar(cctx, name, *arg, &end); | 1703 res = compile_load_scriptvar(cctx, name, *arg, &end, error); |
1702 } | 1704 } |
1703 } | 1705 } |
1704 if (gen_load) | 1706 if (gen_load) |
1705 res = generate_LOAD(cctx, ISN_LOAD, idx, NULL, type); | 1707 res = generate_LOAD(cctx, ISN_LOAD, idx, NULL, type); |
1706 } | 1708 } |
3463 break; | 3465 break; |
3464 case dest_global: | 3466 case dest_global: |
3465 generate_LOAD(cctx, ISN_LOADG, 0, name + 2, type); | 3467 generate_LOAD(cctx, ISN_LOADG, 0, name + 2, type); |
3466 break; | 3468 break; |
3467 case dest_script: | 3469 case dest_script: |
3468 compile_load_scriptvar(cctx, name + (name[1] == ':' ? 2 : 0), NULL, NULL); | 3470 compile_load_scriptvar(cctx, |
3471 name + (name[1] == ':' ? 2 : 0), NULL, NULL, TRUE); | |
3469 break; | 3472 break; |
3470 case dest_env: | 3473 case dest_env: |
3471 // Include $ in the name here | 3474 // Include $ in the name here |
3472 generate_LOAD(cctx, ISN_LOADENV, 0, name, type); | 3475 generate_LOAD(cctx, ISN_LOADENV, 0, name, type); |
3473 break; | 3476 break; |