Patch 9.0.1091
Problem: Assignment to non-existing member causes a crash. (Yegappan
Lakshmanan)
Solution: Give an error message and bail out when a member cannot be found.
Files: src/vim9compile.c, src/vim9class.c, src/testdir/test_vim9_class.vim
*** ../vim-9.0.1090/src/vim9compile.c 2022-12-18 21:42:49.014716925 +0000
--- src/vim9compile.c 2022-12-23 17:46:14.837951644 +0000
***************
*** 1823,1828 ****
--- 1823,1830 ----
class_T *cl = (class_T *)lhs->lhs_type->tt_member;
lhs->lhs_member_type = class_member_type(cl, after + 1,
lhs->lhs_end, &lhs->lhs_member_idx);
+ if (lhs->lhs_member_idx < 0)
+ return FAIL;
}
else
lhs->lhs_member_type = lhs->lhs_type->tt_member;
*** ../vim-9.0.1090/src/vim9class.c 2022-12-20 13:38:18.280419448 +0000
--- src/vim9class.c 2022-12-23 17:41:56.393838113 +0000
***************
*** 569,576 ****
}
/*
! * Find member "name" in class "cl" and return its type.
! * When not found t_any is returned.
*/
type_T *
class_member_type(
--- 569,577 ----
}
/*
! * Find member "name" in class "cl", set "member_idx" to the member index and
! * return its type.
! * When not found "member_idx" is set to -1 and t_any is returned.
*/
type_T *
class_member_type(
***************
*** 591,596 ****
--- 592,599 ----
return m->ocm_type;
}
}
+
+ semsg(_(e_unknown_variable_str), name);
return &t_any;
}
*** ../vim-9.0.1090/src/testdir/test_vim9_class.vim 2022-12-20
13:38:18.280419448 +0000
--- src/testdir/test_vim9_class.vim 2022-12-23 17:53:51.581676540 +0000
***************
*** 111,116 ****
--- 111,127 ----
lines =<< trim END
vim9script
class Something
+ def new()
+ this.state = 0
+ enddef
+ endclass
+ var obj = Something.new()
+ END
+ v9.CheckScriptFailure(lines, 'E1089:')
+
+ lines =<< trim END
+ vim9script
+ class Something
this.count : number
endclass
END
***************
*** 330,336 ****
--- 341,349 ----
assert_equal(0, TextPos.counter)
TextPos.AddToCounter(3)
assert_equal(3, TextPos.counter)
+ assert_fails('echo TextPos.noSuchMember', 'E1338:')
+ assert_fails('TextPos.noSuchMember = 2', 'E1337:')
assert_fails('TextPos.counter += 5', 'E1335')
END
v9.CheckScriptSuccess(lines)
*** ../vim-9.0.1090/src/version.c 2022-12-23 13:18:37.842600801 +0000
--- src/version.c 2022-12-23 17:54:15.385652062 +0000
***************
*** 697,698 ****
--- 697,700 ----
{ /* Add new patch number below this line */
+ /**/
+ 1091,
/**/
--
Trees moving back and forth is what makes the wind blow.
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/20221223175744.513241C0AA3%40moolenaar.net.