mirror of
https://github.com/neovim/neovim
synced 2025-07-16 09:11:51 +00:00
fix: assert failure in VimL expression parser
This commit is contained in:
@ -1264,21 +1264,12 @@ static bool viml_pexpr_handle_bop(const ParserState *const pstate, ExprASTStack
|
|||||||
|| bop_node->type == kExprNodeSubscript)
|
|| bop_node->type == kExprNodeSubscript)
|
||||||
? kEOpLvlSubscript
|
? kEOpLvlSubscript
|
||||||
: node_lvl(*bop_node));
|
: node_lvl(*bop_node));
|
||||||
#ifndef NDEBUG
|
|
||||||
const ExprOpAssociativity bop_node_ass = (
|
|
||||||
(bop_node->type == kExprNodeCall
|
|
||||||
|| bop_node->type == kExprNodeSubscript)
|
|
||||||
? kEOpAssLeft
|
|
||||||
: node_ass(*bop_node));
|
|
||||||
#endif
|
|
||||||
do {
|
do {
|
||||||
ExprASTNode **new_top_node_p = kv_last(*ast_stack);
|
ExprASTNode **new_top_node_p = kv_last(*ast_stack);
|
||||||
ExprASTNode *new_top_node = *new_top_node_p;
|
ExprASTNode *new_top_node = *new_top_node_p;
|
||||||
assert(new_top_node != NULL);
|
assert(new_top_node != NULL);
|
||||||
const ExprOpLvl new_top_node_lvl = node_lvl(*new_top_node);
|
const ExprOpLvl new_top_node_lvl = node_lvl(*new_top_node);
|
||||||
const ExprOpAssociativity new_top_node_ass = node_ass(*new_top_node);
|
const ExprOpAssociativity new_top_node_ass = node_ass(*new_top_node);
|
||||||
assert(bop_node_lvl != new_top_node_lvl
|
|
||||||
|| bop_node_ass == new_top_node_ass);
|
|
||||||
if (top_node_p != NULL
|
if (top_node_p != NULL
|
||||||
&& ((bop_node_lvl > new_top_node_lvl
|
&& ((bop_node_lvl > new_top_node_lvl
|
||||||
|| (bop_node_lvl == new_top_node_lvl
|
|| (bop_node_lvl == new_top_node_lvl
|
||||||
|
@ -2938,6 +2938,13 @@ describe('API', function()
|
|||||||
return ('%s(%s)%s'):format(typ, args, rest)
|
return ('%s(%s)%s'):format(typ, args, rest)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it('does not crash parsing invalid VimL expression #29648', function()
|
||||||
|
api.nvim_input(':<C-r>=')
|
||||||
|
api.nvim_input('1bork/')
|
||||||
|
assert_alive()
|
||||||
|
end)
|
||||||
|
|
||||||
require('test.unit.viml.expressions.parser_tests')(it, _check_parsing, hl, fmtn)
|
require('test.unit.viml.expressions.parser_tests')(it, _check_parsing, hl, fmtn)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user