]> granicus.if.org Git - vim/commitdiff
patch 8.2.1501: Vim9: concatenating to constant reverses order v8.2.1501
authorBram Moolenaar <Bram@vim.org>
Fri, 21 Aug 2020 18:43:17 +0000 (20:43 +0200)
committerBram Moolenaar <Bram@vim.org>
Fri, 21 Aug 2020 18:43:17 +0000 (20:43 +0200)
Problem:    Vim9: concatenating to constant reverses order.
Solution:   Generate constant before option, register and environment
            variable. (closes #6757)

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

index 2c88efbac04126d359c712a02e37f6f71101ad24..312eddfaeb26256934fb861029b3a73454362be2 100644 (file)
@@ -944,6 +944,18 @@ def Test_expr5()
                                + g:ablob)
   assert_equal(0z01ab3344, g:ablob + 0z3344)
   assert_equal(0z01ab01ab, g:ablob + g:ablob)
+
+  # concatenate non-constant to constant
+  let save_path = &path
+  &path = 'b'
+  assert_equal('ab', 'a' .. &path)
+  &path = save_path
+
+  @b = 'b'
+  assert_equal('ab', 'a' .. @b)
+
+  $ENVVAR = 'env'
+  assert_equal('aenv', 'a' .. $ENVVAR)
 enddef
 
 def Test_expr5_vim9script()
index bd836e0700b3d1c3e51d2d3108b536d4afb28212..4e7b9ad1aa232fa594dbe63d11756d730f043c9b 100644 (file)
@@ -754,6 +754,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1501,
 /**/
     1500,
 /**/
index f1936452a94d39940d1e85278b90d94c20bd978b..b9d8caa4e49f17b4fe50570f19179c198cfb951f 100644 (file)
@@ -3402,19 +3402,25 @@ compile_expr7(
        /*
         * Option value: &name
         */
-       case '&':       ret = compile_get_option(arg, cctx);
+       case '&':       if (generate_ppconst(cctx, ppconst) == FAIL)
+                           return FAIL;
+                       ret = compile_get_option(arg, cctx);
                        break;
 
        /*
         * Environment variable: $VAR.
         */
-       case '$':       ret = compile_get_env(arg, cctx);
+       case '$':       if (generate_ppconst(cctx, ppconst) == FAIL)
+                           return FAIL;
+                       ret = compile_get_env(arg, cctx);
                        break;
 
        /*
         * Register contents: @r.
         */
-       case '@':       ret = compile_get_register(arg, cctx);
+       case '@':       if (generate_ppconst(cctx, ppconst) == FAIL)
+                           return FAIL;
+                       ret = compile_get_register(arg, cctx);
                        break;
        /*
         * nested expression: (expression).