@@ -887,6 +887,17 @@ get_lval(
887
887
return NULL ;
888
888
}
889
889
890
+ if (in_vim9script () && lp -> ll_valtype == NULL
891
+ && lp -> ll_tv == & v -> di_tv
892
+ && ht != NULL && ht == get_script_local_ht ())
893
+ {
894
+ svar_T * sv = find_typval_in_script (lp -> ll_tv );
895
+
896
+ // Vim9 script local variable: get the type
897
+ if (sv != NULL )
898
+ lp -> ll_valtype = sv -> sv_type ;
899
+ }
900
+
890
901
len = -1 ;
891
902
if (* p == '.' )
892
903
{
@@ -1037,6 +1048,10 @@ get_lval(
1037
1048
}
1038
1049
}
1039
1050
1051
+ if (lp -> ll_valtype != NULL )
1052
+ // use the type of the member
1053
+ lp -> ll_valtype = lp -> ll_valtype -> tt_member ;
1054
+
1040
1055
if (lp -> ll_di == NULL )
1041
1056
{
1042
1057
// Can't add "v:" or "a:" variable.
@@ -1148,6 +1163,10 @@ get_lval(
1148
1163
return NULL ;
1149
1164
}
1150
1165
1166
+ if (lp -> ll_valtype != NULL )
1167
+ // use the type of the member
1168
+ lp -> ll_valtype = lp -> ll_valtype -> tt_member ;
1169
+
1151
1170
/*
1152
1171
* May need to find the item or absolute index for the second
1153
1172
* index of a range.
@@ -1383,6 +1402,11 @@ set_var_lval(
1383
1402
emsg (_ ("E996: Cannot lock a list or dict" ));
1384
1403
return ;
1385
1404
}
1405
+
1406
+ if (lp -> ll_valtype != NULL
1407
+ && check_typval_type (lp -> ll_valtype , rettv , 0 ) == FAIL )
1408
+ return ;
1409
+
1386
1410
if (lp -> ll_newkey != NULL )
1387
1411
{
1388
1412
if (op != NULL && * op != '=' )
@@ -3960,21 +3984,12 @@ partial_free(partial_T *pt)
3960
3984
else
3961
3985
func_ptr_unref (pt -> pt_func );
3962
3986
3987
+ // Decrease the reference count for the context of a closure. If down
3988
+ // to the minimum it may be time to free it.
3963
3989
if (pt -> pt_funcstack != NULL )
3964
3990
{
3965
- // Decrease the reference count for the context of a closure. If down
3966
- // to zero free it and clear the variables on the stack.
3967
- if (-- pt -> pt_funcstack -> fs_refcount == 0 )
3968
- {
3969
- garray_T * gap = & pt -> pt_funcstack -> fs_ga ;
3970
- typval_T * stack = gap -> ga_data ;
3971
-
3972
- for (i = 0 ; i < gap -> ga_len ; ++ i )
3973
- clear_tv (stack + i );
3974
- ga_clear (gap );
3975
- vim_free (pt -> pt_funcstack );
3976
- }
3977
- pt -> pt_funcstack = NULL ;
3991
+ -- pt -> pt_funcstack -> fs_refcount ;
3992
+ funcstack_check_refcount (pt -> pt_funcstack );
3978
3993
}
3979
3994
3980
3995
vim_free (pt );
@@ -3987,8 +4002,16 @@ partial_free(partial_T *pt)
3987
4002
void
3988
4003
partial_unref (partial_T * pt )
3989
4004
{
3990
- if (pt != NULL && -- pt -> pt_refcount <= 0 )
3991
- partial_free (pt );
4005
+ if (pt != NULL )
4006
+ {
4007
+ if (-- pt -> pt_refcount <= 0 )
4008
+ partial_free (pt );
4009
+
4010
+ // If the reference count goes down to one, the funcstack may be the
4011
+ // only reference and can be freed if no other partials reference it.
4012
+ else if (pt -> pt_refcount == 1 && pt -> pt_funcstack != NULL )
4013
+ funcstack_check_refcount (pt -> pt_funcstack );
4014
+ }
3992
4015
}
3993
4016
3994
4017
/*
0 commit comments