comparison src/vim9script.c @ 20842:bacc2ab11810 v8.2.0973

patch 8.2.0973: Vim9: type is not checked when assigning to a script variable Commit: https://github.com/vim/vim/commit/34db91f7a47b7bd4aabf1e1dfbaa8a08278bf78d Author: Bram Moolenaar <Bram@vim.org> Date: Sat Jun 13 19:00:10 2020 +0200 patch 8.2.0973: Vim9: type is not checked when assigning to a script variable Problem: Vim9: type is not checked when assigning to a script variable. Solution: Check the type.
author Bram Moolenaar <Bram@vim.org>
date Sat, 13 Jun 2020 19:15:03 +0200
parents 0600ab7b9f09
children 1360541e8c74
comparison
equal deleted inserted replaced
20841:f0411e161f00 20842:bacc2ab11810
486 486
487 vim_free(name); 487 vim_free(name);
488 return p; 488 return p;
489 } 489 }
490 490
491 /*
492 * Check if the type of script variable "dest" allows assigning "value".
493 */
494 void
495 check_script_var_type(typval_T *dest, typval_T *value, char_u *name)
496 {
497 scriptitem_T *si = SCRIPT_ITEM(current_sctx.sc_sid);
498 int idx;
499
500 // Find the svar_T in sn_var_vals.
501 for (idx = 0; idx < si->sn_var_vals.ga_len; ++idx)
502 {
503 svar_T *sv = ((svar_T *)si->sn_var_vals.ga_data) + idx;
504
505 if (sv->sv_tv == dest)
506 {
507 if (sv->sv_const)
508 semsg(_(e_readonlyvar), name);
509 else
510 check_type(sv->sv_type, typval2type(value), TRUE);
511 return;
512 }
513 }
514 iemsg("check_script_var_type(): not found");
515 }
491 516
492 #endif // FEAT_EVAL 517 #endif // FEAT_EVAL