comparison src/vim9compile.c @ 21811:3261e28c638a v8.2.1455

patch 8.2.1455: Vim9: crash when using typecast before constant Commit: https://github.com/vim/vim/commit/d1103587cf339feb8c77d282f7f7e92b7cff5add Author: Bram Moolenaar <Bram@vim.org> 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.
author Bram Moolenaar <Bram@vim.org>
date Fri, 14 Aug 2020 22:45:03 +0200
parents 15ed135796fd
children 0deb6f96a5a3
comparison
equal deleted inserted replaced
21810:65ece008fe02 21811:3261e28c638a
3499 return FAIL; 3499 return FAIL;
3500 3500
3501 if (want_type != NULL) 3501 if (want_type != NULL)
3502 { 3502 {
3503 garray_T *stack = &cctx->ctx_type_stack; 3503 garray_T *stack = &cctx->ctx_type_stack;
3504 type_T *actual = ((type_T **)stack->ga_data)[stack->ga_len - 1]; 3504 type_T *actual;
3505 3505
3506 generate_ppconst(cctx, ppconst);
3507 actual = ((type_T **)stack->ga_data)[stack->ga_len - 1];
3506 if (check_type(want_type, actual, FALSE) == FAIL) 3508 if (check_type(want_type, actual, FALSE) == FAIL)
3507 { 3509 {
3508 generate_ppconst(cctx, ppconst);
3509 if (need_type(actual, want_type, -1, cctx, FALSE) == FAIL) 3510 if (need_type(actual, want_type, -1, cctx, FALSE) == FAIL)
3510 return FAIL; 3511 return FAIL;
3511 } 3512 }
3512 } 3513 }
3513 3514
5014 ++cctx->ctx_locals.ga_len; 5015 ++cctx->ctx_locals.ga_len;
5015 if (r == FAIL) 5016 if (r == FAIL)
5016 goto theend; 5017 goto theend;
5017 if (*skipwhite(p) != ']') 5018 if (*skipwhite(p) != ']')
5018 { 5019 {
5020 // this should not happen
5019 emsg(_(e_missbrac)); 5021 emsg(_(e_missbrac));
5020 goto theend; 5022 goto theend;
5021 } 5023 }
5022 if (type == &t_any) 5024 if (type == &t_any)
5023 { 5025 {