Skip to content

Commit e507ff1

Browse files
committed
patch 8.2.2444: Vim9: compile error with combination of operator and list
Problem: Vim9: compile error with combination of operator and list. Solution: Generate constants before parsing a list or dict. (closes #7757)
1 parent 80ad3e2 commit e507ff1

3 files changed

Lines changed: 11 additions & 2 deletions

File tree

src/testdir/test_vim9_expr.vim

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,6 +1083,9 @@ def Test_expr5()
10831083
assert_equal('a0.123', 'a' .. 0.123)
10841084
endif
10851085

1086+
assert_equal(3, 1 + [2, 3, 4][0])
1087+
assert_equal(5, 2 + {key: 3}['key'])
1088+
10861089
set digraph
10871090
assert_equal('val: true', 'val: ' .. &digraph)
10881091
set nodigraph

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+
2444,
753755
/**/
754756
2443,
755757
/**/

src/vim9compile.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4121,13 +4121,17 @@ compile_expr7(
41214121
/*
41224122
* List: [expr, expr]
41234123
*/
4124-
case '[': ret = compile_list(arg, cctx, ppconst);
4124+
case '[': if (generate_ppconst(cctx, ppconst) == FAIL)
4125+
return FAIL;
4126+
ret = compile_list(arg, cctx, ppconst);
41254127
break;
41264128

41274129
/*
41284130
* Dictionary: {'key': val, 'key': val}
41294131
*/
4130-
case '{': ret = compile_dict(arg, cctx, ppconst);
4132+
case '{': if (generate_ppconst(cctx, ppconst) == FAIL)
4133+
return FAIL;
4134+
ret = compile_dict(arg, cctx, ppconst);
41314135
break;
41324136

41334137
/*

0 commit comments

Comments
 (0)