summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-08-21 20:43:17 +0200
committerBram Moolenaar <Bram@vim.org>2020-08-21 20:43:17 +0200
commit3fc71285d5ae7c16cf7be5d997fd1fe140f196da (patch)
tree9d505305858192627564767b9c071a41fcd9d336
parent5d72ce69c8783fd8f1a0355c00806c5084010eec (diff)
patch 8.2.1501: Vim9: concatenating to constant reverses orderv8.2.1501
Problem: Vim9: concatenating to constant reverses order. Solution: Generate constant before option, register and environment variable. (closes #6757)
-rw-r--r--src/testdir/test_vim9_expr.vim12
-rw-r--r--src/version.c2
-rw-r--r--src/vim9compile.c12
3 files changed, 23 insertions, 3 deletions
diff --git a/src/testdir/test_vim9_expr.vim b/src/testdir/test_vim9_expr.vim
index 2c88efbac0..312eddfaeb 100644
--- a/src/testdir/test_vim9_expr.vim
+++ b/src/testdir/test_vim9_expr.vim
@@ -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()
diff --git a/src/version.c b/src/version.c
index bd836e0700..4e7b9ad1aa 100644
--- a/src/version.c
+++ b/src/version.c
@@ -755,6 +755,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1501,
+/**/
1500,
/**/
1499,
diff --git a/src/vim9compile.c b/src/vim9compile.c
index f1936452a9..b9d8caa4e4 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -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).