comparison src/typval.c @ 24936:345619f35112 v8.2.3005

patch 8.2.3005: Vim9: using a void value does not give a proper error message Commit: https://github.com/vim/vim/commit/f57b43c230c23117650c956c1f62546a34500fb6 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Jun 15 22:13:27 2021 +0200 patch 8.2.3005: Vim9: using a void value does not give a proper error message Problem: Vim9: using a void value does not give a proper error message. Solution: Give a clear error message. (clodes https://github.com/vim/vim/issues/8387)
author Bram Moolenaar <Bram@vim.org>
date Tue, 15 Jun 2021 22:15:03 +0200
parents b1093c1ac109
children 0c415a0f54f9
comparison
equal deleted inserted replaced
24935:68f1020e0c69 24936:345619f35112
236 break; 236 break;
237 #endif 237 #endif
238 case VAR_BLOB: 238 case VAR_BLOB:
239 emsg(_("E974: Using a Blob as a Number")); 239 emsg(_("E974: Using a Blob as a Number"));
240 break; 240 break;
241 case VAR_VOID:
242 emsg(_(e_cannot_use_void_value));
243 break;
241 case VAR_UNKNOWN: 244 case VAR_UNKNOWN:
242 case VAR_ANY: 245 case VAR_ANY:
243 case VAR_VOID:
244 case VAR_INSTR: 246 case VAR_INSTR:
245 internal_error_no_abort("tv_get_number(UNKNOWN)"); 247 internal_error_no_abort("tv_get_number(UNKNOWN)");
246 break; 248 break;
247 } 249 }
248 if (denote == NULL) // useful for values that must be unsigned 250 if (denote == NULL) // useful for values that must be unsigned
292 tv_get_bool_chk(typval_T *varp, int *denote) 294 tv_get_bool_chk(typval_T *varp, int *denote)
293 { 295 {
294 return tv_get_bool_or_number_chk(varp, denote, TRUE); 296 return tv_get_bool_or_number_chk(varp, denote, TRUE);
295 } 297 }
296 298
297 #ifdef FEAT_FLOAT 299 #if defined(FEAT_FLOAT) || defined(PROTO)
298 float_T 300 float_T
299 tv_get_float(typval_T *varp) 301 tv_get_float(typval_T *varp)
300 { 302 {
301 switch (varp->v_type) 303 switch (varp->v_type)
302 { 304 {
334 break; 336 break;
335 # endif 337 # endif
336 case VAR_BLOB: 338 case VAR_BLOB:
337 emsg(_("E975: Using a Blob as a Float")); 339 emsg(_("E975: Using a Blob as a Float"));
338 break; 340 break;
341 case VAR_VOID:
342 emsg(_(e_cannot_use_void_value));
343 break;
339 case VAR_UNKNOWN: 344 case VAR_UNKNOWN:
340 case VAR_ANY: 345 case VAR_ANY:
341 case VAR_VOID:
342 case VAR_INSTR: 346 case VAR_INSTR:
343 internal_error_no_abort("tv_get_float(UNKNOWN)"); 347 internal_error_no_abort("tv_get_float(UNKNOWN)");
344 break; 348 break;
345 } 349 }
346 return 0; 350 return 0;
499 break; 503 break;
500 } 504 }
501 return channel_to_string_buf(varp, buf); 505 return channel_to_string_buf(varp, buf);
502 #endif 506 #endif
503 break; 507 break;
508 case VAR_VOID:
509 emsg(_(e_cannot_use_void_value));
510 break;
504 case VAR_UNKNOWN: 511 case VAR_UNKNOWN:
505 case VAR_ANY: 512 case VAR_ANY:
506 case VAR_VOID:
507 case VAR_INSTR: 513 case VAR_INSTR:
508 semsg(_(e_using_invalid_value_as_string_str), 514 semsg(_(e_using_invalid_value_as_string_str),
509 vartype_name(varp->v_type)); 515 vartype_name(varp->v_type));
510 break; 516 break;
511 } 517 }
583 switch (from->v_type) 589 switch (from->v_type)
584 { 590 {
585 case VAR_NUMBER: 591 case VAR_NUMBER:
586 case VAR_BOOL: 592 case VAR_BOOL:
587 case VAR_SPECIAL: 593 case VAR_SPECIAL:
594 case VAR_VOID:
588 to->vval.v_number = from->vval.v_number; 595 to->vval.v_number = from->vval.v_number;
589 break; 596 break;
590 case VAR_FLOAT: 597 case VAR_FLOAT:
591 #ifdef FEAT_FLOAT 598 #ifdef FEAT_FLOAT
592 to->vval.v_float = from->vval.v_float; 599 to->vval.v_float = from->vval.v_float;
657 ++to->vval.v_dict->dv_refcount; 664 ++to->vval.v_dict->dv_refcount;
658 } 665 }
659 break; 666 break;
660 case VAR_UNKNOWN: 667 case VAR_UNKNOWN:
661 case VAR_ANY: 668 case VAR_ANY:
662 case VAR_VOID:
663 internal_error_no_abort("copy_tv(UNKNOWN)"); 669 internal_error_no_abort("copy_tv(UNKNOWN)");
664 break; 670 break;
665 } 671 }
666 } 672 }
667 673