# HG changeset patch # User Christian Brabandt # Date 1702885506 -3600 # Node ID ba282a0dec3d91a1f5e2ad4a3931e3a8370c9706 # Parent 0af858a7b97a03c3b86e8813616d355f3f69c282 patch 9.0.2174: Vim9: segfault when assigning to type Commit: https://github.com/vim/vim/commit/b5011089860b24f60db1a74f91c0adf8897c4401 Author: Ernie Rael Date: Mon Dec 18 08:34:41 2023 +0100 patch 9.0.2174: Vim9: segfault when assigning to type Problem: Vim9: segfault when assigning to type Solution: do not clear typeval, add missing patch number closes: #13714 closes: #13715 Signed-off-by: Ernie Rael Signed-off-by: Christian Brabandt diff --git a/src/evalvars.c b/src/evalvars.c --- a/src/evalvars.c +++ b/src/evalvars.c @@ -3978,7 +3978,6 @@ set_var_const( { semsg(_(e_cannot_modify_typealias), di->di_tv.vval.v_typealias->ta_name); - clear_tv(&di->di_tv); goto failed; } diff --git a/src/testdir/test_vim9_assign.vim b/src/testdir/test_vim9_assign.vim --- a/src/testdir/test_vim9_assign.vim +++ b/src/testdir/test_vim9_assign.vim @@ -3076,6 +3076,7 @@ def Test_type_check() vim9script class A endclass + type T = number var N: number = 1 var S: string = 'abc' var d: dict = {} @@ -3091,6 +3092,7 @@ def Test_type_check() assert_fails('Fn = N', 'E1012: Type mismatch; expected func(...): unknown but got number') assert_fails('A = N', 'E1012: Type mismatch; expected class but got number') assert_fails('o = N', 'E1012: Type mismatch; expected object but got number') + assert_fails('T = N', 'E1395: Type alias "T" cannot be modified') # Use a compound operator with different LHS types assert_fails('d += N', 'E734: Wrong variable type for +=') @@ -3099,6 +3101,7 @@ def Test_type_check() assert_fails('Fn += N', 'E734: Wrong variable type for +=') assert_fails('A += N', 'E734: Wrong variable type for +=') assert_fails('o += N', 'E734: Wrong variable type for +=') + assert_fails('T += N', 'E1395: Type alias "T" cannot be modified') # Assign to a number variable assert_fails('N = d', 'E1012: Type mismatch; expected number but got dict') @@ -3107,6 +3110,7 @@ def Test_type_check() assert_fails('N = Fn', 'E1012: Type mismatch; expected number but got func([unknown]): number') assert_fails('N = A', 'E1405: Class "A" cannot be used as a value') assert_fails('N = o', 'E1012: Type mismatch; expected number but got object') + assert_fails('N = T', 'E1403: Type alias "T" cannot be used as a value') # Use a compound operator with different RHS types assert_fails('N += d', 'E734: Wrong variable type for +=') @@ -3115,6 +3119,7 @@ def Test_type_check() assert_fails('N += Fn', 'E734: Wrong variable type for +=') assert_fails('N += A', 'E1405: Class "A" cannot be used as a value') assert_fails('N += o', 'E1320: Using an Object as a Number') + assert_fails('N += T', 'E1403: Type alias "T" cannot be used as a value') # Initialize multiple variables using [] assert_fails('var [X1: number, Y: number] = [1, d]', 'E1012: Type mismatch; expected number but got dict') @@ -3123,6 +3128,7 @@ def Test_type_check() assert_fails('var [X4: number, Y: number] = [1, Fn]', 'E1012: Type mismatch; expected number but got func([unknown]): number') assert_fails('var [X7: number, Y: number] = [1, A]', 'E1405: Class "A" cannot be used as a value') assert_fails('var [X8: number, Y: number] = [1, o]', 'E1012: Type mismatch; expected number but got object') + assert_fails('var [X8: number, Y: number] = [1, T]', 'E1403: Type alias "T" cannot be used as a value') # String concatenation with various LHS types assert_fails('S ..= d', 'E734: Wrong variable type for .=') @@ -3131,6 +3137,7 @@ def Test_type_check() assert_fails('S ..= Fn', 'E734: Wrong variable type for .=') assert_fails('S ..= A', 'E1405: Class "A" cannot be used as a value') assert_fails('S ..= o', 'E1324: Using an Object as a String') + assert_fails('S ..= T', 'E1403: Type alias "T" cannot be used as a value') # String concatenation with various RHS types assert_fails('d ..= S', 'E734: Wrong variable type for .=') @@ -3139,6 +3146,7 @@ def Test_type_check() assert_fails('Fn ..= S', 'E734: Wrong variable type for .=') assert_fails('A ..= S', 'E734: Wrong variable type for .=') assert_fails('o ..= S', 'E734: Wrong variable type for .=') + assert_fails('T ..= S', 'E1395: Type alias "T" cannot be modified') END v9.CheckSourceSuccess(lines) diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -705,10 +705,14 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 2174, +/**/ 2173, /**/ 2172, /**/ + 2171, +/**/ 2170, /**/ 2169,