0
0
mirror of https://github.com/vim/vim.git synced 2025-09-25 03:54:15 -04:00

patch 9.0.2169: Vim9: builtin funcs may accept a non-value

Problem:  Vim9: builtin funcs may accept a non-value
Solution: Restrict builtin functions that accept `type`

This PR finishes off detection and prevention of using a type as a
value. It takes care of builtin functions. However there are some
builtin functions, that need to be able to handle types as well as
non-args: instanceof(), type(), typename(), string().

A "bit", FE_X, is added to funcentry_T; when set, the builtin function
can handle a type (class or type-alias) in addition to a value.

Noteworthy change: Discovered that in compile_call() the builtin add()
is compiled inline instead of calling the builtin. Had to add a check
there.

closes: #13688

Signed-off-by: Ernie Rael <errael@raelity.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Ernie Rael
2023-12-16 14:03:33 +01:00
committed by Christian Brabandt
parent df12e39b8b
commit d8bf87c9fb
7 changed files with 354 additions and 42 deletions

View File

@@ -1143,6 +1143,8 @@ compile_call(
if (STRCMP(name, "add") == 0 && argcount == 2)
{
type_T *type = get_decl_type_on_stack(cctx, 1);
if (check_type_is_value(get_type_on_stack(cctx, 0)) == FAIL)
goto theend;
// add() can be compiled to instructions if we know the type
if (type->tt_type == VAR_LIST)