Mercurial > vim
comparison src/vim9instr.c @ 32051:e8c60d35fce3 v9.0.1357
patch 9.0.1357: using null_object results in an internal error
Commit: https://github.com/vim/vim/commit/c4e1b86cb0d88fa5ec1141d3c600e026dcc1bc21
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Feb 26 18:58:23 2023 +0000
patch 9.0.1357: using null_object results in an internal error
Problem: Using null_object results in an internal error. (Ernie Rael)
Solution: Add instructions for pushing an object and class. (closes https://github.com/vim/vim/issues/12044)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 26 Feb 2023 20:00:03 +0100 |
parents | f1a5e67e9a1b |
children | 76fd08a4ae1d |
comparison
equal
deleted
inserted
replaced
32050:181589e7fc64 | 32051:e8c60d35fce3 |
---|---|
654 isn->isn_arg.type.ct_type = alloc_type(expected); | 654 isn->isn_arg.type.ct_type = alloc_type(expected); |
655 return OK; | 655 return OK; |
656 } | 656 } |
657 | 657 |
658 /* | 658 /* |
659 * Generate an ISN_PUSHOBJ instruction. Object is always NULL. | |
660 */ | |
661 static int | |
662 generate_PUSHOBJ(cctx_T *cctx) | |
663 { | |
664 RETURN_OK_IF_SKIP(cctx); | |
665 if (generate_instr_type(cctx, ISN_PUSHOBJ, &t_any) == NULL) | |
666 return FAIL; | |
667 return OK; | |
668 } | |
669 | |
670 /* | |
671 * Generate an ISN_PUSHCLASS instruction. "class" can be NULL. | |
672 */ | |
673 static int | |
674 generate_PUSHCLASS(cctx_T *cctx, class_T *class) | |
675 { | |
676 RETURN_OK_IF_SKIP(cctx); | |
677 isn_T *isn = generate_instr_type(cctx, ISN_PUSHCLASS, | |
678 class == NULL ? &t_any : &class->class_type); | |
679 if (isn == NULL) | |
680 return FAIL; | |
681 isn->isn_arg.class = class; | |
682 if (class != NULL) | |
683 ++class->class_refcount; | |
684 return OK; | |
685 } | |
686 | |
687 /* | |
659 * Generate a PUSH instruction for "tv". | 688 * Generate a PUSH instruction for "tv". |
660 * "tv" will be consumed or cleared. | 689 * "tv" will be consumed or cleared. |
661 */ | 690 */ |
662 int | 691 int |
663 generate_tv_PUSH(cctx_T *cctx, typval_T *tv) | 692 generate_tv_PUSH(cctx_T *cctx, typval_T *tv) |
715 return FAIL; | 744 return FAIL; |
716 break; | 745 break; |
717 case VAR_STRING: | 746 case VAR_STRING: |
718 generate_PUSHS(cctx, &tv->vval.v_string); | 747 generate_PUSHS(cctx, &tv->vval.v_string); |
719 tv->vval.v_string = NULL; | 748 tv->vval.v_string = NULL; |
749 break; | |
750 case VAR_OBJECT: | |
751 if (tv->vval.v_object != NULL) | |
752 { | |
753 emsg(_(e_cannot_use_non_null_object)); | |
754 return FAIL; | |
755 } | |
756 generate_PUSHOBJ(cctx); | |
757 break; | |
758 case VAR_CLASS: | |
759 generate_PUSHCLASS(cctx, tv->vval.v_class); | |
720 break; | 760 break; |
721 default: | 761 default: |
722 siemsg("constant type %d not supported", tv->v_type); | 762 siemsg("constant type %d not supported", tv->v_type); |
723 clear_tv(tv); | 763 clear_tv(tv); |
724 return FAIL; | 764 return FAIL; |
1935 | 1975 |
1936 if (type->tt_type == VAR_ANY || type->tt_type == VAR_UNKNOWN) | 1976 if (type->tt_type == VAR_ANY || type->tt_type == VAR_UNKNOWN) |
1937 ret_type = &t_any; | 1977 ret_type = &t_any; |
1938 else if (type->tt_type == VAR_FUNC || type->tt_type == VAR_PARTIAL) | 1978 else if (type->tt_type == VAR_FUNC || type->tt_type == VAR_PARTIAL) |
1939 { | 1979 { |
1940 if (check_func_args_from_type(cctx, type, argcount, at_top, name) == FAIL) | 1980 if (check_func_args_from_type(cctx, type, argcount, at_top, name) |
1981 == FAIL) | |
1941 return FAIL; | 1982 return FAIL; |
1942 | 1983 |
1943 ret_type = type->tt_member; | 1984 ret_type = type->tt_member; |
1944 if (ret_type == &t_unknown) | 1985 if (ret_type == &t_unknown) |
1945 // return type not known yet, use a runtime check | 1986 // return type not known yet, use a runtime check |
2463 vim_free(isn->isn_arg.storeopt.so_name); | 2504 vim_free(isn->isn_arg.storeopt.so_name); |
2464 break; | 2505 break; |
2465 | 2506 |
2466 case ISN_PUSHBLOB: // push blob isn_arg.blob | 2507 case ISN_PUSHBLOB: // push blob isn_arg.blob |
2467 blob_unref(isn->isn_arg.blob); | 2508 blob_unref(isn->isn_arg.blob); |
2509 break; | |
2510 | |
2511 case ISN_PUSHCLASS: | |
2512 class_unref(isn->isn_arg.class); | |
2468 break; | 2513 break; |
2469 | 2514 |
2470 case ISN_UCALL: | 2515 case ISN_UCALL: |
2471 vim_free(isn->isn_arg.ufunc.cuf_name); | 2516 vim_free(isn->isn_arg.ufunc.cuf_name); |
2472 break; | 2517 break; |
2657 case ISN_PUSHBOOL: | 2702 case ISN_PUSHBOOL: |
2658 case ISN_PUSHCHANNEL: | 2703 case ISN_PUSHCHANNEL: |
2659 case ISN_PUSHF: | 2704 case ISN_PUSHF: |
2660 case ISN_PUSHJOB: | 2705 case ISN_PUSHJOB: |
2661 case ISN_PUSHNR: | 2706 case ISN_PUSHNR: |
2707 case ISN_PUSHOBJ: | |
2662 case ISN_PUSHSPEC: | 2708 case ISN_PUSHSPEC: |
2663 case ISN_PUT: | 2709 case ISN_PUT: |
2664 case ISN_REDIREND: | 2710 case ISN_REDIREND: |
2665 case ISN_REDIRSTART: | 2711 case ISN_REDIRSTART: |
2666 case ISN_RETURN: | 2712 case ISN_RETURN: |