Mercurial > vim
diff src/vim9expr.c @ 33326:4e531adb3fac v9.0.1928
patch 9.0.1928: Vim9: constructor type checking bug
Commit: https://github.com/vim/vim/commit/b895b0fabce7d952a6617eb69fc1e1597ece8b00
Author: h-east <h.east.727@gmail.com>
Date: Sun Sep 24 15:46:31 2023 +0200
patch 9.0.1928: Vim9: constructor type checking bug
Problem: Vim9: constructor type checking bug
Solution: Fix class constructor regression
closes: #13102
closes: #13113
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: h-east <h.east.727@gmail.com>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 24 Sep 2023 16:00:07 +0200 |
parents | 0c3553cfe22e |
children | 41b50abddeea |
line wrap: on
line diff
--- a/src/vim9expr.c +++ b/src/vim9expr.c @@ -395,8 +395,8 @@ compile_class_object_index(cctx_T *cctx, if (type->tt_type == VAR_OBJECT && (cl->class_flags & (CLASS_INTERFACE | CLASS_EXTENDED))) - return generate_CALL(cctx, ufunc, cl, fi, type, argcount); - return generate_CALL(cctx, ufunc, NULL, 0, type, argcount); + return generate_CALL(cctx, ufunc, cl, fi, argcount); + return generate_CALL(cctx, ufunc, NULL, 0, argcount); } if (type->tt_type == VAR_OBJECT) @@ -977,7 +977,6 @@ compile_call( int has_g_namespace; ca_special_T special_fn; imported_T *import; - type_T *type; if (varlen >= sizeof(namebuf)) { @@ -1061,7 +1060,6 @@ compile_call( if (compile_arguments(arg, cctx, &argcount, special_fn) == FAIL) goto theend; - type = get_decl_type_on_stack(cctx, 1); is_autoload = vim_strchr(name, AUTOLOAD_CHAR) != NULL; if (ASCII_ISLOWER(*name) && name[1] != ':' && !is_autoload) { @@ -1079,6 +1077,8 @@ compile_call( if (STRCMP(name, "add") == 0 && argcount == 2) { + type_T *type = get_decl_type_on_stack(cctx, 1); + // add() can be compiled to instructions if we know the type if (type->tt_type == VAR_LIST) { @@ -1128,7 +1128,7 @@ compile_call( { if (!func_is_global(ufunc)) { - res = generate_CALL(cctx, ufunc, NULL, 0, type, argcount); + res = generate_CALL(cctx, ufunc, NULL, 0, argcount); goto theend; } if (!has_g_namespace @@ -1147,7 +1147,7 @@ compile_call( if (cctx->ctx_ufunc->uf_defclass == cl) { res = generate_CALL(cctx, cl->class_class_functions[mi], NULL, - 0, type, argcount); + 0, argcount); } else { @@ -1175,7 +1175,7 @@ compile_call( // If we can find a global function by name generate the right call. if (ufunc != NULL) { - res = generate_CALL(cctx, ufunc, NULL, 0, type, argcount); + res = generate_CALL(cctx, ufunc, NULL, 0, argcount); goto theend; }