Skip to content

Commit 54d7f18

Browse files
yegappanchrisbra
authored andcommitted
patch 9.1.1099: Vim9: import with extends may crash
Problem: Vim9: import with extends may crash, v9.1.1087 wasn't the correct way to fix it) Solution: When using an import class, Check for a valid class member variable at compile time (Yegappan Lakshmanan) related: #16601 closes: #16603 Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
1 parent e3647c8 commit 54d7f18

5 files changed

Lines changed: 9 additions & 13 deletions

File tree

src/testdir/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ clean:
9696
-rm -f opt_test.vim test_result.log $(CLEANUP_FILES)
9797
-rm -rf $(RM_ON_RUN) $(RM_ON_START)
9898
-rm -f valgrind.*
99-
-rm -f asan.*
99+
-rm -f asan.* asan_test_*
100100
-rm -f guidialog guidialogfile
101101

102102
# Delete the files produced by benchmarking, so they can run again.

src/testdir/test_vim9_import.vim

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3454,8 +3454,7 @@ def Test_vim9_import_and_class_extends()
34543454
var myView = View.new('This should be ok')
34553455
assert_equal('This should be ok', myView.content.value)
34563456
END
3457-
# TODO: The root cause will be identified later.
3458-
v9.CheckScriptFailure(lines, 'E1099: Unknown error while executing new', 7)
3457+
v9.CheckScriptFailure(lines, 'E1376: Object variable "value2" accessible only using class "Run" object', 2)
34593458
enddef
34603459

34613460
" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,8 @@ static char *(features[]) =
704704

705705
static int included_patches[] =
706706
{ /* Add new patch number below this line */
707+
/**/
708+
1099,
707709
/**/
708710
1098,
709711
/**/

src/vim9compile.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2496,9 +2496,10 @@ compile_load_lhs(
24962496
lhs->lhs_type = cctx->ctx_type_stack.ga_len == 0 ? &t_void
24972497
: get_type_on_stack(cctx, 0);
24982498

2499-
if (lhs->lhs_type->tt_type == VAR_OBJECT)
2499+
if (lhs->lhs_type->tt_type == VAR_CLASS
2500+
|| lhs->lhs_type->tt_type == VAR_OBJECT)
25002501
{
2501-
// Check whether the object variable is modifiable
2502+
// Check whether the class or object variable is modifiable
25022503
if (!lhs_class_member_modifiable(lhs, var_start, cctx))
25032504
return FAIL;
25042505
}

src/vim9execute.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2461,14 +2461,8 @@ execute_storeindex(isn_T *iptr, ectx_T *ectx)
24612461
otv = class->class_members_tv;
24622462
}
24632463

2464-
if (otv != NULL)
2465-
{
2466-
clear_tv(&otv[lidx]);
2467-
otv[lidx] = *tv;
2468-
}
2469-
else
2470-
status = FAIL;
2471-
2464+
clear_tv(&otv[lidx]);
2465+
otv[lidx] = *tv;
24722466
}
24732467
else
24742468
{

0 commit comments

Comments
 (0)