diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-01-31 21:47:42 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-01-31 21:47:42 +0100 |
commit | e507ff15d52653dad3054ddc0073708977621c0c (patch) | |
tree | ccba7ad92530997c85d1a3d0944a8c4b0afd2194 | |
parent | 80ad3e25697cf759d5af5cd13e8b124c1cd657f5 (diff) | |
download | vim-git-e507ff15d52653dad3054ddc0073708977621c0c.tar.gz |
patch 8.2.2444: Vim9: compile error with combination of operator and listv8.2.2444
Problem: Vim9: compile error with combination of operator and list.
Solution: Generate constants before parsing a list or dict. (closes #7757)
-rw-r--r-- | src/testdir/test_vim9_expr.vim | 3 | ||||
-rw-r--r-- | src/version.c | 2 | ||||
-rw-r--r-- | src/vim9compile.c | 8 |
3 files changed, 11 insertions, 2 deletions
diff --git a/src/testdir/test_vim9_expr.vim b/src/testdir/test_vim9_expr.vim index 2239e76df..aead431f5 100644 --- a/src/testdir/test_vim9_expr.vim +++ b/src/testdir/test_vim9_expr.vim @@ -1083,6 +1083,9 @@ def Test_expr5() assert_equal('a0.123', 'a' .. 0.123) endif + assert_equal(3, 1 + [2, 3, 4][0]) + assert_equal(5, 2 + {key: 3}['key']) + set digraph assert_equal('val: true', 'val: ' .. &digraph) set nodigraph diff --git a/src/version.c b/src/version.c index b3d4feffd..b320943a3 100644 --- a/src/version.c +++ b/src/version.c @@ -751,6 +751,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 2444, +/**/ 2443, /**/ 2442, diff --git a/src/vim9compile.c b/src/vim9compile.c index 5b9f7f518..a9edc802d 100644 --- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -4121,13 +4121,17 @@ compile_expr7( /* * List: [expr, expr] */ - case '[': ret = compile_list(arg, cctx, ppconst); + case '[': if (generate_ppconst(cctx, ppconst) == FAIL) + return FAIL; + ret = compile_list(arg, cctx, ppconst); break; /* * Dictionary: {'key': val, 'key': val} */ - case '{': ret = compile_dict(arg, cctx, ppconst); + case '{': if (generate_ppconst(cctx, ppconst) == FAIL) + return FAIL; + ret = compile_dict(arg, cctx, ppconst); break; /* |