diff src/testdir/test_vim9_typealias.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
line wrap: on
line diff
--- a/src/testdir/test_vim9_typealias.vim
+++ b/src/testdir/test_vim9_typealias.vim
@@ -212,7 +212,7 @@ def Test_typealias()
     enddef
     Foo()
   END
-  v9.CheckSourceFailure(lines, 'E1406: Cannot use a Typealias as a variable or value', 1)
+  v9.CheckSourceFailure(lines, 'E1407: Cannot use a Typealias as a variable or value', 1)
 
   # Using type alias in an expression (script level)
   lines =<< trim END
@@ -516,8 +516,18 @@ def Test_typealias_instanceof()
     var o = C.new()
     assert_equal(1, instanceof(o, Ctype))
     type Ntype = number
-    assert_fails('instanceof(o, Ntype)', 'E693: List or Class required for argument 2')
-    assert_equal(1, instanceof(o, [Ctype]))
+    assert_fails('instanceof(o, Ntype)', 'E693: Class or class typealias required for argument 2')
+    assert_fails('instanceof(o, Ctype, Ntype)', 'E693: Class or class typealias required for argument 3')
+
+    def F()
+      var x = instanceof(o, Ntype)
+    enddef
+    assert_fails('F()', 'E693: Class or class typealias required for argument 2')
+
+    def G(): bool
+      return instanceof(o, Ctype)
+    enddef
+    assert_equal(1, G())
   END
   v9.CheckScriptSuccess(lines)
 enddef