Skip to content

Commit 71abe48

Browse files
committed
patch 8.2.1686: Vim9: "const!" not sufficiently tested
Problem: Vim9: "const!" not sufficiently tested. Solution: Add a few more test cases. Fix type checking.
1 parent 0b4c66c commit 71abe48

3 files changed

Lines changed: 23 additions & 2 deletions

File tree

src/testdir/test_vim9_script.vim

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -831,6 +831,24 @@ def Test_const()
831831
list->assert_equal([4, 2, 3])
832832
const! other = [5, 6, 7]
833833
other->assert_equal([5, 6, 7])
834+
835+
let varlist = [7, 8]
836+
const! constlist = [1, varlist, 3]
837+
varlist[0] = 77
838+
# TODO: does not work yet
839+
# constlist[1][1] = 88
840+
let cl = constlist[1]
841+
cl[1] = 88
842+
constlist->assert_equal([1, [77, 88], 3])
843+
844+
let vardict = #{five: 5, six: 6}
845+
const! constdict = #{one: 1, two: vardict, three: 3}
846+
vardict['five'] = 55
847+
# TODO: does not work yet
848+
# constdict['two']['six'] = 66
849+
let cd = constdict['two']
850+
cd['six'] = 66
851+
constdict->assert_equal(#{one: 1, two: #{five: 55, six: 66}, three: 3})
834852
END
835853
CheckDefAndScriptSuccess(lines)
836854
enddef

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,8 @@ static char *(features[]) =
750750

751751
static int included_patches[] =
752752
{ /* Add new patch number below this line */
753+
/**/
754+
1686,
753755
/**/
754756
1685,
755757
/**/

src/vim9compile.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5066,12 +5066,13 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
50665066
{
50675067
type_T *use_type = lvar->lv_type;
50685068

5069-
// without operator type is here, otherwise below
5069+
// without operator check type here, otherwise below
50705070
if (has_index)
50715071
{
50725072
use_type = use_type->tt_member;
50735073
if (use_type == NULL)
5074-
use_type = &t_void;
5074+
// could be indexing "any"
5075+
use_type = &t_any;
50755076
}
50765077
if (need_type(stacktype, use_type, -1, cctx, FALSE)
50775078
== FAIL)

0 commit comments

Comments
 (0)