forked from aniani/vim
patch 8.2.3015: Vim9: Assigning to @# requires a string
Problem: Vim9: Assigning to @# requires a string. (Naohiro Ono) Solution: Accent a number or a string. (closes #8396)
This commit is contained in:
parent
6e9695525e
commit
74f4a965bc
@ -418,6 +418,9 @@ EXTERN type_T t_blob INIT6(VAR_BLOB, 0, 0, TTFLAG_STATIC, NULL, NULL);
|
|||||||
EXTERN type_T t_job INIT6(VAR_JOB, 0, 0, TTFLAG_STATIC, NULL, NULL);
|
EXTERN type_T t_job INIT6(VAR_JOB, 0, 0, TTFLAG_STATIC, NULL, NULL);
|
||||||
EXTERN type_T t_channel INIT6(VAR_CHANNEL, 0, 0, TTFLAG_STATIC, NULL, NULL);
|
EXTERN type_T t_channel INIT6(VAR_CHANNEL, 0, 0, TTFLAG_STATIC, NULL, NULL);
|
||||||
|
|
||||||
|
// Special value used for @#.
|
||||||
|
EXTERN type_T t_number_or_string INIT6(VAR_STRING, 0, 0, TTFLAG_STATIC, NULL, NULL);
|
||||||
|
|
||||||
EXTERN type_T t_func_unknown INIT6(VAR_FUNC, -1, 0, TTFLAG_STATIC, &t_unknown, NULL);
|
EXTERN type_T t_func_unknown INIT6(VAR_FUNC, -1, 0, TTFLAG_STATIC, &t_unknown, NULL);
|
||||||
EXTERN type_T t_func_void INIT6(VAR_FUNC, -1, 0, TTFLAG_STATIC, &t_void, NULL);
|
EXTERN type_T t_func_void INIT6(VAR_FUNC, -1, 0, TTFLAG_STATIC, &t_void, NULL);
|
||||||
EXTERN type_T t_func_any INIT6(VAR_FUNC, -1, 0, TTFLAG_STATIC, &t_any, NULL);
|
EXTERN type_T t_func_any INIT6(VAR_FUNC, -1, 0, TTFLAG_STATIC, &t_any, NULL);
|
||||||
|
@ -1820,6 +1820,19 @@ def Test_assign_command_modifier()
|
|||||||
CheckDefAndScriptSuccess(lines)
|
CheckDefAndScriptSuccess(lines)
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
|
def Test_assign_alt_buf_register()
|
||||||
|
var lines =<< trim END
|
||||||
|
edit 'file_b1'
|
||||||
|
var b1 = bufnr()
|
||||||
|
edit 'file_b2'
|
||||||
|
var b2 = bufnr()
|
||||||
|
assert_equal(b1, bufnr('#'))
|
||||||
|
@# = b2
|
||||||
|
assert_equal(b2, bufnr('#'))
|
||||||
|
END
|
||||||
|
CheckDefAndScriptSuccess(lines)
|
||||||
|
enddef
|
||||||
|
|
||||||
def Test_script_funcref_case()
|
def Test_script_funcref_case()
|
||||||
var lines =<< trim END
|
var lines =<< trim END
|
||||||
var Len = (s: string): number => len(s) + 1
|
var Len = (s: string): number => len(s) + 1
|
||||||
|
@ -750,6 +750,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
3015,
|
||||||
/**/
|
/**/
|
||||||
3014,
|
3014,
|
||||||
/**/
|
/**/
|
||||||
|
@ -5852,7 +5852,7 @@ get_var_dest(
|
|||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
*dest = dest_reg;
|
*dest = dest_reg;
|
||||||
*type = &t_string;
|
*type = name[1] == '#' ? &t_number_or_string : &t_string;
|
||||||
}
|
}
|
||||||
else if (STRNCMP(name, "g:", 2) == 0)
|
else if (STRNCMP(name, "g:", 2) == 0)
|
||||||
{
|
{
|
||||||
@ -5927,7 +5927,8 @@ generate_store_var(
|
|||||||
case dest_env:
|
case dest_env:
|
||||||
return generate_STORE(cctx, ISN_STOREENV, 0, name + 1);
|
return generate_STORE(cctx, ISN_STOREENV, 0, name + 1);
|
||||||
case dest_reg:
|
case dest_reg:
|
||||||
return generate_STORE(cctx, ISN_STOREREG, name[1], NULL);
|
return generate_STORE(cctx, ISN_STOREREG,
|
||||||
|
name[1] == '@' ? '"' : name[1], NULL);
|
||||||
case dest_vimvar:
|
case dest_vimvar:
|
||||||
return generate_STORE(cctx, ISN_STOREV, vimvaridx, NULL);
|
return generate_STORE(cctx, ISN_STOREV, vimvaridx, NULL);
|
||||||
case dest_script:
|
case dest_script:
|
||||||
@ -6843,10 +6844,20 @@ compile_assignment(char_u *arg, exarg_T *eap, cmdidx_T cmdidx, cctx_T *cctx)
|
|||||||
goto theend;
|
goto theend;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (*p != '=' && need_type(rhs_type, lhs.lhs_member_type,
|
else
|
||||||
|
{
|
||||||
|
type_T *lhs_type = lhs.lhs_member_type;
|
||||||
|
|
||||||
|
// Special case: assigning to @# can use a number or a
|
||||||
|
// string.
|
||||||
|
if (lhs_type == &t_number_or_string
|
||||||
|
&& rhs_type->tt_type == VAR_NUMBER)
|
||||||
|
lhs_type = &t_number;
|
||||||
|
if (*p != '=' && need_type(rhs_type, lhs_type,
|
||||||
-1, 0, cctx, FALSE, FALSE) == FAIL)
|
-1, 0, cctx, FALSE, FALSE) == FAIL)
|
||||||
goto theend;
|
goto theend;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (cmdidx == CMD_final)
|
else if (cmdidx == CMD_final)
|
||||||
{
|
{
|
||||||
emsg(_(e_final_requires_a_value));
|
emsg(_(e_final_requires_a_value));
|
||||||
|
@ -2182,8 +2182,7 @@ exec_instructions(ectx_T *ectx)
|
|||||||
|
|
||||||
--ectx->ec_stack.ga_len;
|
--ectx->ec_stack.ga_len;
|
||||||
tv = STACK_TV_BOT(0);
|
tv = STACK_TV_BOT(0);
|
||||||
write_reg_contents(reg == '@' ? '"' : reg,
|
write_reg_contents(reg, tv_get_string(tv), -1, FALSE);
|
||||||
tv_get_string(tv), -1, FALSE);
|
|
||||||
clear_tv(tv);
|
clear_tv(tv);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user