mirror of
https://github.com/vim/vim.git
synced 2025-09-23 03:43:49 -04:00
patch 9.0.0627: "const" and "final" both make the type a constant
Problem: "const" and "final" both make the type a constant. (Daniel Steinberg) Solution: Only have "const" make the type a constant.
This commit is contained in:
@@ -471,7 +471,7 @@ set_var_type(lvar_T *lvar, type_T *type_arg, cctx_T *cctx)
|
||||
{
|
||||
type_T *type = type_arg;
|
||||
|
||||
if (lvar->lv_const && (type->tt_flags & TTFLAG_CONST) == 0)
|
||||
if (lvar->lv_const == ASSIGN_CONST && (type->tt_flags & TTFLAG_CONST) == 0)
|
||||
{
|
||||
if (type->tt_flags & TTFLAG_STATIC)
|
||||
// entry in static_types[] is followed by const type
|
||||
@@ -487,6 +487,8 @@ set_var_type(lvar_T *lvar, type_T *type_arg, cctx_T *cctx)
|
||||
|
||||
/*
|
||||
* Reserve space for a local variable.
|
||||
* "assign" can be ASSIGN_VAR for :var, ASSIGN_CONST for :const and
|
||||
* ASSIGN_FINAL for :final.
|
||||
* Return the variable or NULL if it failed.
|
||||
*/
|
||||
lvar_T *
|
||||
@@ -494,7 +496,7 @@ reserve_local(
|
||||
cctx_T *cctx,
|
||||
char_u *name,
|
||||
size_t len,
|
||||
int isConst,
|
||||
int assign,
|
||||
type_T *type)
|
||||
{
|
||||
lvar_T *lvar;
|
||||
@@ -519,7 +521,7 @@ reserve_local(
|
||||
lvar->lv_idx = dfunc->df_var_names.ga_len;
|
||||
|
||||
lvar->lv_name = vim_strnsave(name, len == 0 ? STRLEN(name) : len);
|
||||
lvar->lv_const = isConst;
|
||||
lvar->lv_const = assign;
|
||||
if (type == &t_unknown || type == &t_any)
|
||||
// type not known yet, may be inferred from RHS
|
||||
lvar->lv_type = type;
|
||||
@@ -993,7 +995,7 @@ compile_nested_function(exarg_T *eap, cctx_T *cctx, garray_T *lines_to_free)
|
||||
{
|
||||
// Define a local variable for the function reference.
|
||||
lvar = reserve_local(cctx, func_name, name_end - name_start,
|
||||
TRUE, ufunc->uf_func_type);
|
||||
ASSIGN_CONST, ufunc->uf_func_type);
|
||||
if (lvar == NULL)
|
||||
goto theend;
|
||||
if (generate_FUNCREF(cctx, ufunc, &funcref_isn) == FAIL)
|
||||
@@ -1691,8 +1693,10 @@ compile_lhs(
|
||||
return FAIL;
|
||||
|
||||
// New local variable.
|
||||
int assign = cmdidx == CMD_final ? ASSIGN_FINAL
|
||||
: cmdidx == CMD_const ? ASSIGN_CONST : ASSIGN_VAR;
|
||||
lhs->lhs_lvar = reserve_local(cctx, var_start, lhs->lhs_varlen,
|
||||
cmdidx == CMD_final || cmdidx == CMD_const, lhs->lhs_type);
|
||||
assign, lhs->lhs_type);
|
||||
if (lhs->lhs_lvar == NULL)
|
||||
return FAIL;
|
||||
lhs->lhs_new_local = TRUE;
|
||||
@@ -1769,7 +1773,8 @@ compile_assign_lhs(
|
||||
return FAIL;
|
||||
}
|
||||
if (!is_decl && lhs->lhs_lvar != NULL
|
||||
&& lhs->lhs_lvar->lv_const && !lhs->lhs_has_index)
|
||||
&& lhs->lhs_lvar->lv_const != ASSIGN_VAR
|
||||
&& !lhs->lhs_has_index)
|
||||
{
|
||||
semsg(_(e_cannot_assign_to_constant), lhs->lhs_name);
|
||||
return FAIL;
|
||||
|
Reference in New Issue
Block a user