mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
patch 9.0.2027: Vim9: no support for bitwise operators in lambda funcs
Problem: Vim9: no support for bitwise operators in lambda funcs Solution: move "evaluate" assignment a bit up in order to decide to perform bitwise operations closes: #13342 closes: #13345 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
This commit is contained in:
committed by
Christian Brabandt
parent
ae3cfa47d3
commit
de3295dd0c
28
src/eval.c
28
src/eval.c
@@ -3515,7 +3515,8 @@ eval5(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
|
||||
return OK;
|
||||
|
||||
// Handle a bitwise left or right shift operator
|
||||
if (rettv->v_type != VAR_NUMBER)
|
||||
evaluate = evalarg == NULL ? 0 : (evalarg->eval_flags & EVAL_EVALUATE);
|
||||
if (evaluate && rettv->v_type != VAR_NUMBER)
|
||||
{
|
||||
// left operand should be a number
|
||||
emsg(_(e_bitshift_ops_must_be_number));
|
||||
@@ -3523,7 +3524,6 @@ eval5(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
evaluate = evalarg == NULL ? 0 : (evalarg->eval_flags & EVAL_EVALUATE);
|
||||
vim9script = in_vim9script();
|
||||
if (getnext)
|
||||
{
|
||||
@@ -3553,20 +3553,20 @@ eval5(char_u **arg, typval_T *rettv, evalarg_T *evalarg)
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
if (var2.v_type != VAR_NUMBER || var2.vval.v_number < 0)
|
||||
{
|
||||
// right operand should be a positive number
|
||||
if (var2.v_type != VAR_NUMBER)
|
||||
emsg(_(e_bitshift_ops_must_be_number));
|
||||
else
|
||||
emsg(_(e_bitshift_ops_must_be_positive));
|
||||
clear_tv(rettv);
|
||||
clear_tv(&var2);
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
if (evaluate)
|
||||
{
|
||||
if (var2.v_type != VAR_NUMBER || var2.vval.v_number < 0)
|
||||
{
|
||||
// right operand should be a positive number
|
||||
if (var2.v_type != VAR_NUMBER)
|
||||
emsg(_(e_bitshift_ops_must_be_number));
|
||||
else
|
||||
emsg(_(e_bitshift_ops_must_be_positive));
|
||||
clear_tv(rettv);
|
||||
clear_tv(&var2);
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
if (var2.vval.v_number > MAX_LSHIFT_BITS)
|
||||
// shifting more bits than we have always results in zero
|
||||
rettv->vval.v_number = 0;
|
||||
|
Reference in New Issue
Block a user