comparison src/testdir/test_vim9_assign.vim @ 33924:ccdb948c7273 v9.0.2160

patch 9.0.2160: instanceof() should use varargs as second arg Commit: https://github.com/vim/vim/commit/2025af165ec68d831f0f0f668a3ceac3f39142ef Author: Ernie Rael <errael@raelity.com> Date: Tue Dec 12 16:58:00 2023 +0100 patch 9.0.2160: instanceof() should use varargs as second arg Problem: instanceof() should use varargs as second arg Solution: Modify `instanceof()` to use varargs instead of list Modify `instanceof()` to use varargs instead of list Valid `instanceof()` arguments are `type`s. A `type` is not a value; it cannot be added to a list. This change is non-compatible with the current usage of instanceof; but instanceof is relatively new and it's a trivial change. fixes: #13421 closes: #13644 Signed-off-by: Ernie Rael <errael@raelity.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Tue, 12 Dec 2023 17:15:03 +0100
parents a259471e74fe
children aceaf677dd92
comparison
equal deleted inserted replaced
33923:b1e48fed6e55 33924:ccdb948c7273
3062 vim9script 3062 vim9script
3063 class C 3063 class C
3064 endclass 3064 endclass
3065 class D 3065 class D
3066 endclass 3066 endclass
3067 assert_fails('C = D', 'E1403: Class "D" cannot be used as a value') 3067 assert_fails('C = D', 'E1405: Class "D" cannot be used as a value')
3068 END 3068 END
3069 v9.CheckSourceSuccess(lines) 3069 v9.CheckSourceSuccess(lines)
3070 enddef 3070 enddef
3071 3071
3072 " Test for using various types (dict, list, blob, funcref, class) as variable 3072 " Test for using various types (dict, list, blob, funcref, class) as variable
3103 # Assign to a number variable 3103 # Assign to a number variable
3104 assert_fails('N = d', 'E1012: Type mismatch; expected number but got dict<number>') 3104 assert_fails('N = d', 'E1012: Type mismatch; expected number but got dict<number>')
3105 assert_fails('N = l', 'E1012: Type mismatch; expected number but got list<number>') 3105 assert_fails('N = l', 'E1012: Type mismatch; expected number but got list<number>')
3106 assert_fails('N = b', 'E1012: Type mismatch; expected number but got blob') 3106 assert_fails('N = b', 'E1012: Type mismatch; expected number but got blob')
3107 assert_fails('N = Fn', 'E1012: Type mismatch; expected number but got func([unknown]): number') 3107 assert_fails('N = Fn', 'E1012: Type mismatch; expected number but got func([unknown]): number')
3108 assert_fails('N = A', 'E1403: Class "A" cannot be used as a value') 3108 assert_fails('N = A', 'E1405: Class "A" cannot be used as a value')
3109 assert_fails('N = o', 'E1012: Type mismatch; expected number but got object<A>') 3109 assert_fails('N = o', 'E1012: Type mismatch; expected number but got object<A>')
3110 3110
3111 # Use a compound operator with different RHS types 3111 # Use a compound operator with different RHS types
3112 assert_fails('N += d', 'E734: Wrong variable type for +=') 3112 assert_fails('N += d', 'E734: Wrong variable type for +=')
3113 assert_fails('N += l', 'E734: Wrong variable type for +=') 3113 assert_fails('N += l', 'E734: Wrong variable type for +=')
3114 assert_fails('N += b', 'E974: Using a Blob as a Number') 3114 assert_fails('N += b', 'E974: Using a Blob as a Number')
3115 assert_fails('N += Fn', 'E734: Wrong variable type for +=') 3115 assert_fails('N += Fn', 'E734: Wrong variable type for +=')
3116 assert_fails('N += A', 'E1403: Class "A" cannot be used as a value') 3116 assert_fails('N += A', 'E1405: Class "A" cannot be used as a value')
3117 assert_fails('N += o', 'E1320: Using an Object as a Number') 3117 assert_fails('N += o', 'E1320: Using an Object as a Number')
3118 3118
3119 # Initialize multiple variables using [] 3119 # Initialize multiple variables using []
3120 assert_fails('var [X1: number, Y: number] = [1, d]', 'E1012: Type mismatch; expected number but got dict<number>') 3120 assert_fails('var [X1: number, Y: number] = [1, d]', 'E1012: Type mismatch; expected number but got dict<number>')
3121 assert_fails('var [X2: number, Y: number] = [1, l]', 'E1012: Type mismatch; expected number but got list<number>') 3121 assert_fails('var [X2: number, Y: number] = [1, l]', 'E1012: Type mismatch; expected number but got list<number>')
3122 assert_fails('var [X3: number, Y: number] = [1, b]', 'E1012: Type mismatch; expected number but got blob') 3122 assert_fails('var [X3: number, Y: number] = [1, b]', 'E1012: Type mismatch; expected number but got blob')
3123 assert_fails('var [X4: number, Y: number] = [1, Fn]', 'E1012: Type mismatch; expected number but got func([unknown]): number') 3123 assert_fails('var [X4: number, Y: number] = [1, Fn]', 'E1012: Type mismatch; expected number but got func([unknown]): number')
3124 assert_fails('var [X7: number, Y: number] = [1, A]', 'E1403: Class "A" cannot be used as a value') 3124 assert_fails('var [X7: number, Y: number] = [1, A]', 'E1405: Class "A" cannot be used as a value')
3125 assert_fails('var [X8: number, Y: number] = [1, o]', 'E1012: Type mismatch; expected number but got object<A>') 3125 assert_fails('var [X8: number, Y: number] = [1, o]', 'E1012: Type mismatch; expected number but got object<A>')
3126 3126
3127 # String concatenation with various LHS types 3127 # String concatenation with various LHS types
3128 assert_fails('S ..= d', 'E734: Wrong variable type for .=') 3128 assert_fails('S ..= d', 'E734: Wrong variable type for .=')
3129 assert_fails('S ..= l', 'E734: Wrong variable type for .=') 3129 assert_fails('S ..= l', 'E734: Wrong variable type for .=')
3130 assert_fails('S ..= b', 'E976: Using a Blob as a String') 3130 assert_fails('S ..= b', 'E976: Using a Blob as a String')
3131 assert_fails('S ..= Fn', 'E734: Wrong variable type for .=') 3131 assert_fails('S ..= Fn', 'E734: Wrong variable type for .=')
3132 assert_fails('S ..= A', 'E1403: Class "A" cannot be used as a value') 3132 assert_fails('S ..= A', 'E1405: Class "A" cannot be used as a value')
3133 assert_fails('S ..= o', 'E1324: Using an Object as a String') 3133 assert_fails('S ..= o', 'E1324: Using an Object as a String')
3134 3134
3135 # String concatenation with various RHS types 3135 # String concatenation with various RHS types
3136 assert_fails('d ..= S', 'E734: Wrong variable type for .=') 3136 assert_fails('d ..= S', 'E734: Wrong variable type for .=')
3137 assert_fails('l ..= S', 'E734: Wrong variable type for .=') 3137 assert_fails('l ..= S', 'E734: Wrong variable type for .=')