To: vim_dev@googlegroups.com Subject: Patch 8.2.1455 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.1455 Problem: Vim9: crash when using typecast before constant. Solution: Generate constant before checking type. Add tets. Files: src/vim9compile.c, src/testdir/test_vim9_expr.vim *** ../vim-8.2.1454/src/vim9compile.c 2020-08-14 22:16:29.586423086 +0200 --- src/vim9compile.c 2020-08-14 22:36:53.720574591 +0200 *************** *** 3501,3511 **** if (want_type != NULL) { garray_T *stack = &cctx->ctx_type_stack; ! type_T *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; } --- 3501,3512 ---- if (want_type != NULL) { garray_T *stack = &cctx->ctx_type_stack; ! 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) { if (need_type(actual, want_type, -1, cctx, FALSE) == FAIL) return FAIL; } *************** *** 5016,5021 **** --- 5017,5023 ---- goto theend; if (*skipwhite(p) != ']') { + // this should not happen emsg(_(e_missbrac)); goto theend; } *** ../vim-8.2.1454/src/testdir/test_vim9_expr.vim 2020-08-14 22:16:29.586423086 +0200 --- src/testdir/test_vim9_expr.vim 2020-08-14 22:43:05.706345080 +0200 *************** *** 1324,1329 **** --- 1324,1335 ---- 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 = /dev/oven /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///