forked from aniani/vim
patch 9.0.1091: assignment to non-existing member causes a crash
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.
This commit is contained in:
parent
c9207d5d79
commit
f54cedd676
@ -108,6 +108,17 @@ def Test_class_basic()
|
|||||||
END
|
END
|
||||||
v9.CheckScriptFailure(lines, 'E1022:')
|
v9.CheckScriptFailure(lines, 'E1022:')
|
||||||
|
|
||||||
|
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
|
lines =<< trim END
|
||||||
vim9script
|
vim9script
|
||||||
class Something
|
class Something
|
||||||
@ -330,7 +341,9 @@ def Test_class_member_access()
|
|||||||
assert_equal(0, TextPos.counter)
|
assert_equal(0, TextPos.counter)
|
||||||
TextPos.AddToCounter(3)
|
TextPos.AddToCounter(3)
|
||||||
assert_equal(3, TextPos.counter)
|
assert_equal(3, TextPos.counter)
|
||||||
|
assert_fails('echo TextPos.noSuchMember', 'E1338:')
|
||||||
|
|
||||||
|
assert_fails('TextPos.noSuchMember = 2', 'E1337:')
|
||||||
assert_fails('TextPos.counter += 5', 'E1335')
|
assert_fails('TextPos.counter += 5', 'E1335')
|
||||||
END
|
END
|
||||||
v9.CheckScriptSuccess(lines)
|
v9.CheckScriptSuccess(lines)
|
||||||
|
@ -695,6 +695,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1091,
|
||||||
/**/
|
/**/
|
||||||
1090,
|
1090,
|
||||||
/**/
|
/**/
|
||||||
|
@ -569,8 +569,9 @@ cleanup:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Find member "name" in class "cl" and return its type.
|
* Find member "name" in class "cl", set "member_idx" to the member index and
|
||||||
* When not found t_any is returned.
|
* return its type.
|
||||||
|
* When not found "member_idx" is set to -1 and t_any is returned.
|
||||||
*/
|
*/
|
||||||
type_T *
|
type_T *
|
||||||
class_member_type(
|
class_member_type(
|
||||||
@ -591,6 +592,8 @@ class_member_type(
|
|||||||
return m->ocm_type;
|
return m->ocm_type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
semsg(_(e_unknown_variable_str), name);
|
||||||
return &t_any;
|
return &t_any;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1823,6 +1823,8 @@ compile_lhs(
|
|||||||
class_T *cl = (class_T *)lhs->lhs_type->tt_member;
|
class_T *cl = (class_T *)lhs->lhs_type->tt_member;
|
||||||
lhs->lhs_member_type = class_member_type(cl, after + 1,
|
lhs->lhs_member_type = class_member_type(cl, after + 1,
|
||||||
lhs->lhs_end, &lhs->lhs_member_idx);
|
lhs->lhs_end, &lhs->lhs_member_idx);
|
||||||
|
if (lhs->lhs_member_idx < 0)
|
||||||
|
return FAIL;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
lhs->lhs_member_type = lhs->lhs_type->tt_member;
|
lhs->lhs_member_type = lhs->lhs_type->tt_member;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user