Skip to content

Commit 3fc7128

Browse files
committed
patch 8.2.1501: Vim9: concatenating to constant reverses order
Problem: Vim9: concatenating to constant reverses order. Solution: Generate constant before option, register and environment variable. (closes #6757)
1 parent 5d72ce6 commit 3fc7128

3 files changed

Lines changed: 23 additions & 3 deletions

File tree

src/testdir/test_vim9_expr.vim

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -944,6 +944,18 @@ def Test_expr5()
944944
+ g:ablob)
945945
assert_equal(0z01ab3344, g:ablob + 0z3344)
946946
assert_equal(0z01ab01ab, g:ablob + g:ablob)
947+
948+
# concatenate non-constant to constant
949+
let save_path = &path
950+
&path = 'b'
951+
assert_equal('ab', 'a' .. &path)
952+
&path = save_path
953+
954+
@b = 'b'
955+
assert_equal('ab', 'a' .. @b)
956+
957+
$ENVVAR = 'env'
958+
assert_equal('aenv', 'a' .. $ENVVAR)
947959
enddef
948960

949961
def Test_expr5_vim9script()

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,8 @@ static char *(features[]) =
754754

755755
static int included_patches[] =
756756
{ /* Add new patch number below this line */
757+
/**/
758+
1501,
757759
/**/
758760
1500,
759761
/**/

src/vim9compile.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3402,19 +3402,25 @@ compile_expr7(
34023402
/*
34033403
* Option value: &name
34043404
*/
3405-
case '&': ret = compile_get_option(arg, cctx);
3405+
case '&': if (generate_ppconst(cctx, ppconst) == FAIL)
3406+
return FAIL;
3407+
ret = compile_get_option(arg, cctx);
34063408
break;
34073409

34083410
/*
34093411
* Environment variable: $VAR.
34103412
*/
3411-
case '$': ret = compile_get_env(arg, cctx);
3413+
case '$': if (generate_ppconst(cctx, ppconst) == FAIL)
3414+
return FAIL;
3415+
ret = compile_get_env(arg, cctx);
34123416
break;
34133417

34143418
/*
34153419
* Register contents: @r.
34163420
*/
3417-
case '@': ret = compile_get_register(arg, cctx);
3421+
case '@': if (generate_ppconst(cctx, ppconst) == FAIL)
3422+
return FAIL;
3423+
ret = compile_get_register(arg, cctx);
34183424
break;
34193425
/*
34203426
* nested expression: (expression).

0 commit comments

Comments
 (0)