# HG changeset patch # User Bram Moolenaar # Date 1597437903 -7200 # Node ID 3261e28c638a0834c6d9c87763308e3c32cae0d2 # Parent 65ece008fe027f1ebf9ca16fd7916399b5d0fe28 patch 8.2.1455: Vim9: crash when using typecast before constant Commit: https://github.com/vim/vim/commit/d1103587cf339feb8c77d282f7f7e92b7cff5add Author: Bram Moolenaar Date: Fri Aug 14 22:44:25 2020 +0200 patch 8.2.1455: Vim9: crash when using typecast before constant Problem: Vim9: crash when using typecast before constant. Solution: Generate constant before checking type. Add tets. diff --git a/src/testdir/test_vim9_expr.vim b/src/testdir/test_vim9_expr.vim --- a/src/testdir/test_vim9_expr.vim +++ b/src/testdir/test_vim9_expr.vim @@ -1324,6 +1324,12 @@ let $TESTVAR = 'testvar' def Test_expr7t() let ls: list = ['a', g:string_empty] let ln: list = [g:anint, g:alsoint] + let nr = 234 + assert_equal(234, nr) + + call CheckDefFailure(["let x = 123"], 'E1010:') + call CheckDefFailure(["let x = 123"], 'E1068:') + call CheckDefFailure(["let x = ctx_type_stack; - type_T *actual = ((type_T **)stack->ga_data)[stack->ga_len - 1]; - + type_T *actual; + + generate_ppconst(cctx, ppconst); + actual = ((type_T **)stack->ga_data)[stack->ga_len - 1]; if (check_type(want_type, actual, FALSE) == FAIL) { - generate_ppconst(cctx, ppconst); if (need_type(actual, want_type, -1, cctx, FALSE) == FAIL) return FAIL; } @@ -5016,6 +5017,7 @@ compile_assignment(char_u *arg, exarg_T goto theend; if (*skipwhite(p) != ']') { + // this should not happen emsg(_(e_missbrac)); goto theend; }