]> granicus.if.org Git - vim/commitdiff
patch 8.2.2444: Vim9: compile error with combination of operator and list v8.2.2444
authorBram Moolenaar <Bram@vim.org>
Sun, 31 Jan 2021 20:47:42 +0000 (21:47 +0100)
committerBram Moolenaar <Bram@vim.org>
Sun, 31 Jan 2021 20:47:42 +0000 (21:47 +0100)
Problem:    Vim9: compile error with combination of operator and list.
Solution:   Generate constants before parsing a list or dict. (closes #7757)

src/testdir/test_vim9_expr.vim
src/version.c
src/vim9compile.c

index 2239e76df9a1c617cecdb7a8c2f27f1c8c430477..aead431f5aef89d5cb6962e4f6da10bc38d794c7 100644 (file)
@@ -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
index b3d4feffd8e2289ffbe11224f961d49b971541fb..b320943a3a4ce660501beacee5539bd60c17dd91 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2444,
 /**/
     2443,
 /**/
index 5b9f7f5184ef197d3f591a88cef912a0475c40ae..a9edc802ddc96ea1ba8897d4522e9d681bf37330 100644 (file)
@@ -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;
 
        /*