Mercurial > vim
diff src/vim9expr.c @ 32822:b3a42579bb3f v9.0.1724
patch 9.0.1724: vim9class constructor argument type checking bug
Commit: https://github.com/vim/vim/commit/2261c89a49ff2115e1ccc9ab9211e9f0d5a37578
Author: h-east <h.east.727@gmail.com>
Date: Wed Aug 16 21:49:54 2023 +0900
patch 9.0.1724: vim9class constructor argument type checking bug
Problem: vim9class constructor argument type checking bug
Solution: fix it
closes: #12816
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 | Thu, 17 Aug 2023 22:45:03 +0200 |
parents | cdab211f342a |
children | a8561f9b47aa |
line wrap: on
line diff
--- a/src/vim9expr.c +++ b/src/vim9expr.c @@ -358,8 +358,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, argcount); - return generate_CALL(cctx, ufunc, NULL, 0, argcount); + return generate_CALL(cctx, ufunc, cl, fi, type, argcount); + return generate_CALL(cctx, ufunc, NULL, 0, type, argcount); } if (type->tt_type == VAR_OBJECT) @@ -932,6 +932,7 @@ compile_call( int has_g_namespace; ca_special_T special_fn; imported_T *import; + type_T *type; if (varlen >= sizeof(namebuf)) { @@ -1015,6 +1016,7 @@ 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) { @@ -1032,8 +1034,6 @@ 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) { @@ -1080,7 +1080,7 @@ compile_call( { if (!func_is_global(ufunc)) { - res = generate_CALL(cctx, ufunc, NULL, 0, argcount); + res = generate_CALL(cctx, ufunc, NULL, 0, type, argcount); goto theend; } if (!has_g_namespace @@ -1109,7 +1109,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, argcount); + res = generate_CALL(cctx, ufunc, NULL, 0, type, argcount); goto theend; }