mirror of
https://github.com/vim/vim.git
synced 2025-09-23 03:43:49 -04:00
patch 8.2.1408: Vim9: type casting not supported
Problem: Vim9: type casting not supported. Solution: Introduce type casting.
This commit is contained in:
@@ -3401,6 +3401,56 @@ error_white_both(char_u *op, int len)
|
||||
semsg(_(e_white_both), buf);
|
||||
}
|
||||
|
||||
/*
|
||||
* <type>expr7: runtime type check / conversion
|
||||
*/
|
||||
static int
|
||||
compile_expr7t(char_u **arg, cctx_T *cctx, ppconst_T *ppconst)
|
||||
{
|
||||
type_T *want_type = NULL;
|
||||
|
||||
// Recognize <type>
|
||||
if (**arg == '<' && eval_isnamec1((*arg)[1]))
|
||||
{
|
||||
int called_emsg_before = called_emsg;
|
||||
|
||||
++*arg;
|
||||
want_type = parse_type(arg, cctx->ctx_type_list);
|
||||
if (called_emsg != called_emsg_before)
|
||||
return FAIL;
|
||||
|
||||
if (**arg != '>')
|
||||
{
|
||||
if (*skipwhite(*arg) == '>')
|
||||
semsg(_(e_no_white_before), ">");
|
||||
else
|
||||
emsg(_("E1104: Missing >"));
|
||||
return FAIL;
|
||||
}
|
||||
++*arg;
|
||||
if (may_get_next_line_error(*arg - 1, arg, cctx) == FAIL)
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
if (compile_expr7(arg, cctx, ppconst) == FAIL)
|
||||
return FAIL;
|
||||
|
||||
if (want_type != NULL)
|
||||
{
|
||||
garray_T *stack = &cctx->ctx_type_stack;
|
||||
type_T *actual = ((type_T **)stack->ga_data)[stack->ga_len - 1];
|
||||
|
||||
if (check_type(want_type, actual, FALSE) == FAIL)
|
||||
{
|
||||
generate_ppconst(cctx, ppconst);
|
||||
if (need_type(actual, want_type, -1, cctx, FALSE) == FAIL)
|
||||
return FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* * number multiplication
|
||||
* / number division
|
||||
@@ -3414,7 +3464,7 @@ compile_expr6(char_u **arg, cctx_T *cctx, ppconst_T *ppconst)
|
||||
int ppconst_used = ppconst->pp_used;
|
||||
|
||||
// get the first expression
|
||||
if (compile_expr7(arg, cctx, ppconst) == FAIL)
|
||||
if (compile_expr7t(arg, cctx, ppconst) == FAIL)
|
||||
return FAIL;
|
||||
|
||||
/*
|
||||
@@ -3441,7 +3491,7 @@ compile_expr6(char_u **arg, cctx_T *cctx, ppconst_T *ppconst)
|
||||
return FAIL;
|
||||
|
||||
// get the second expression
|
||||
if (compile_expr7(arg, cctx, ppconst) == FAIL)
|
||||
if (compile_expr7t(arg, cctx, ppconst) == FAIL)
|
||||
return FAIL;
|
||||
|
||||
if (ppconst->pp_used == ppconst_used + 2
|
||||
|
Reference in New Issue
Block a user