patch 9.0.2184: Vim9: inconsistent :type/:class messages
Problem: Vim9: inconsistent :type/:class messages
Solution: Update the Messages (Ernie Rael)
closes: #13706
Signed-off-by: Ernie Rael <errael@raelity.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/testdir/test_vim9_assign.vim b/src/testdir/test_vim9_assign.vim
index f904696..aef09c5 100644
--- a/src/testdir/test_vim9_assign.vim
+++ b/src/testdir/test_vim9_assign.vim
@@ -3090,18 +3090,18 @@
assert_fails('l = N', 'E1012: Type mismatch; expected list<number> but got number')
assert_fails('b = N', 'E1012: Type mismatch; expected blob but got number')
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('A = N', 'E1405: Class "A" cannot be used as a value')
assert_fails('o = N', 'E1012: Type mismatch; expected object<A> but got number')
- assert_fails('T = N', 'E1395: Type alias "T" cannot be modified')
+ assert_fails('T = N', 'E1403: Type alias "T" cannot be used as a value')
# Use a compound operator with different LHS types
assert_fails('d += N', 'E734: Wrong variable type for +=')
assert_fails('l += N', 'E734: Wrong variable type for +=')
assert_fails('b += N', 'E734: Wrong variable type for +=')
assert_fails('Fn += N', 'E734: Wrong variable type for +=')
- assert_fails('A += N', 'E734: Wrong variable type for +=')
+ assert_fails('A += N', 'E1405: Class "A" cannot be used as a value')
assert_fails('o += N', 'E734: Wrong variable type for +=')
- assert_fails('T += N', 'E1395: Type alias "T" cannot be modified')
+ assert_fails('T += N', 'E1403: Type alias "T" cannot be used as a value')
# Assign to a number variable
assert_fails('N = d', 'E1012: Type mismatch; expected number but got dict<number>')
@@ -3144,9 +3144,9 @@
assert_fails('l ..= S', 'E734: Wrong variable type for .=')
assert_fails('b ..= S', 'E734: Wrong variable type for .=')
assert_fails('Fn ..= S', 'E734: Wrong variable type for .=')
- assert_fails('A ..= S', 'E734: Wrong variable type for .=')
+ assert_fails('A ..= S', 'E1405: Class "A" cannot be used as a value')
assert_fails('o ..= S', 'E734: Wrong variable type for .=')
- assert_fails('T ..= S', 'E1395: Type alias "T" cannot be modified')
+ assert_fails('T ..= S', 'E1403: Type alias "T" cannot be used as a value')
END
v9.CheckSourceSuccess(lines)
diff --git a/src/testdir/test_vim9_class.vim b/src/testdir/test_vim9_class.vim
index e2c61b0..b34d2ad 100644
--- a/src/testdir/test_vim9_class.vim
+++ b/src/testdir/test_vim9_class.vim
@@ -242,7 +242,7 @@
if A
endif
END
- v9.CheckSourceFailure(lines, 'E1319: Using a Class as a Number', 4)
+ v9.CheckSourceFailure(lines, 'E1405: Class "A" cannot be used as a value', 4)
# Test for using object as a bool
lines =<< trim END
@@ -281,7 +281,7 @@
endclass
:exe 'call ' .. A
END
- v9.CheckSourceFailure(lines, 'E1323: Using a Class as a String', 4)
+ v9.CheckSourceFailure(lines, 'E1405: Class "A" cannot be used as a value', 4)
# Test for using object as a string
lines =<< trim END
diff --git a/src/testdir/test_vim9_disassemble.vim b/src/testdir/test_vim9_disassemble.vim
index 4e81122..1a192cc 100644
--- a/src/testdir/test_vim9_disassemble.vim
+++ b/src/testdir/test_vim9_disassemble.vim
@@ -3193,7 +3193,7 @@
unlet g:instr
enddef
-" Disassemble instructions for ISN_COMPARECLASS and ISN_COMPAREOBJECT
+" Disassemble instructions for ISN_COMPAREOBJECT
def Test_disassemble_compare_class_object()
var lines =<< trim END
vim9script
@@ -3202,8 +3202,6 @@
class B
endclass
def Foo(a: A, b: B)
- if A == B
- endif
if a == b
endif
enddef
@@ -3211,19 +3209,13 @@
END
v9.CheckScriptSuccess(lines)
assert_match('<SNR>\d*_Foo\_s*' ..
- 'if A == B\_s*' ..
- '0 LOADSCRIPT A-0 from .*\_s*' ..
- '1 LOADSCRIPT B-1 from .*\_s*' ..
- '2 COMPARECLASS ==\_s*' ..
+ 'if a == b\_s*' ..
+ '0 LOAD arg\[-2\]\_s*' ..
+ '1 LOAD arg\[-1\]\_s*' ..
+ '2 COMPAREOBJECT ==\_s*' ..
'3 JUMP_IF_FALSE -> 4\_s*' ..
'endif\_s*' ..
- 'if a == b\_s*' ..
- '4 LOAD arg\[-2\]\_s*' ..
- '5 LOAD arg\[-1\]\_s*' ..
- '6 COMPAREOBJECT ==\_s*' ..
- '7 JUMP_IF_FALSE -> 8\_s*' ..
- 'endif\_s*' ..
- '8 RETURN void', g:instr)
+ '4 RETURN void', g:instr)
unlet g:instr
enddef
diff --git a/src/testdir/test_vim9_typealias.vim b/src/testdir/test_vim9_typealias.vim
index 4f88768..4155744 100644
--- a/src/testdir/test_vim9_typealias.vim
+++ b/src/testdir/test_vim9_typealias.vim
@@ -18,7 +18,7 @@
assert_equal('typealias<list<string>>', typename(ListOfStrings))
assert_equal(v:t_typealias, type(ListOfStrings))
assert_equal('ListOfStrings', string(ListOfStrings))
- assert_equal(false, null == ListOfStrings)
+ assert_fails('var x = null == ListOfStrings', 'E1403: Type alias "ListOfStrings" cannot be used as a value')
END
v9.CheckSourceSuccess(lines)
@@ -36,7 +36,7 @@
assert_equal('typealias<list<string>>', typename(ListOfStrings))
assert_equal(v:t_typealias, type(ListOfStrings))
assert_equal('ListOfStrings', string(ListOfStrings))
- assert_equal(false, null == ListOfStrings)
+ #assert_equal(false, null == ListOfStrings)
enddef
Bar()
END
@@ -201,7 +201,7 @@
type MyType = list<number>
MyType = [1, 2, 3]
END
- v9.CheckSourceFailure(lines, 'E1395: Type alias "MyType" cannot be modified', 3)
+ v9.CheckSourceFailure(lines, 'E1403: Type alias "MyType" cannot be used as a value', 3)
# Assigning a type alias (def function level)
lines =<< trim END
@@ -219,11 +219,11 @@
vim9script
type MyType = list<number>
assert_fails('var m = MyType', 'E1403: Type alias "MyType" cannot be used as a value')
- assert_fails('var i = MyType + 1', 'E1400: Using type alias "MyType" as a Number')
- assert_fails('var f = 1.0 + MyType', 'E1400: Using type alias "MyType" as a Number')
- assert_fails('MyType += 10', 'E1395: Type alias "MyType" cannot be modified')
- assert_fails('var x = $"-{MyType}-"', 'E1402: Using type alias "MyType" as a String')
- assert_fails('var x = MyType[1]', 'E909: Cannot index a special variable')
+ assert_fails('var i = MyType + 1', 'E1403: Type alias "MyType" cannot be used as a value')
+ assert_fails('var f = 1.0 + MyType', 'E1403: Type alias "MyType" cannot be used as a value')
+ assert_fails('MyType += 10', 'E1403: Type alias "MyType" cannot be used as a value')
+ assert_fails('var x = $"-{MyType}-"', 'E1403: Type alias "MyType" cannot be used as a value')
+ assert_fails('var x = MyType[1]', 'E1403: Type alias "MyType" cannot be used as a value')
END
v9.CheckSourceSuccess(lines)
@@ -236,7 +236,7 @@
enddef
Foo()
END
- v9.CheckSourceFailure(lines, 'E1051: Wrong argument type for +', 1)
+ v9.CheckSourceFailure(lines, 'E1407: Cannot use a Typealias as a variable or value', 1)
# Using type alias in an expression (def function level)
lines =<< trim END
@@ -305,7 +305,7 @@
var n: number
var x = A == n
END
- v9.CheckSourceFailure(lines, 'E1072: Cannot compare typealias with number', 4)
+ v9.CheckSourceFailure(lines, 'E1403: Type alias "A" cannot be used as a value', 4)
# Comparing type alias with a number (def function level)
lines =<< trim END
@@ -317,7 +317,7 @@
enddef
Foo()
END
- v9.CheckSourceFailure(lines, 'E1072: Cannot compare typealias with number', 2)
+ v9.CheckSourceFailure(lines, 'E1407: Cannot use a Typealias as a variable or value', 2)
# casting a number to a type alias (script level)
lines =<< trim END