patch 9.0.2174: Vim9: segfault when assigning to type

Commit: 
https://github.com/vim/vim/commit/b5011089860b24f60db1a74f91c0adf8897c4401
Author: Ernie Rael <err...@raelity.com>
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 <err...@raelity.com>
    Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/src/evalvars.c b/src/evalvars.c
index 343f6367d..f787e81cc 100644
--- 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
index d582000be..c6828e32d 100644
--- 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<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)
 
diff --git a/src/version.c b/src/version.c
index 779e11696..50660311d 100644
--- a/src/version.c
+++ b/src/version.c
@@ -704,10 +704,14 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2174,
 /**/
     2173,
 /**/
     2172,
+/**/
+    2171,
 /**/
     2170,
 /**/

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/E1rF8JG-0015tn-A2%40256bit.org.

Raspunde prin e-mail lui