]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.0.2174: Vim9: segfault when assigning to type v9.0.2174
authorErnie Rael <errael@raelity.com>
Mon, 18 Dec 2023 07:34:41 +0000 (08:34 +0100)
committerChristian Brabandt <cb@256bit.org>
Mon, 18 Dec 2023 07:34:41 +0000 (08:34 +0100)
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 <errael@raelity.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/evalvars.c
src/testdir/test_vim9_assign.vim
src/version.c

index 343f6367dc889cea34d6e3cef31e0942489dd8ae..f787e81cc3bc98d1b4610e0a887c504007a307e4 100644 (file)
@@ -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;
            }
 
index d582000be11f6ae978198626df4861875ae769a3..c6828e32dffc5c6817752df47035aafff0178011 100644 (file)
@@ -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<number> = {}
@@ -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<A> but got number')
     assert_fails('o = N', 'E1012: Type mismatch; expected object<A> 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<number>')
@@ -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<A>')
+    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<number>')
@@ -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<A>')
+    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)
 
index 779e1169653d337ba73a274fffdf0b796b09c2a3..50660311da60d2438e34baf1fadc94296aba17a2 100644 (file)
@@ -704,10 +704,14 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2174,
 /**/
     2173,
 /**/
     2172,
+/**/
+    2171,
 /**/
     2170,
 /**/