diff options
author | Ernie Rael <errael@raelity.com> | 2023-08-27 18:40:26 +0200 |
---|---|---|
committer | Christian Brabandt <cb@256bit.org> | 2023-08-27 18:40:26 +0200 |
commit | 5c018bee0e1e272774584cfb1577327fbb67254a (patch) | |
tree | 8ac0883f1e7b9ea2fea36e27d4a293a0223af2d0 /src/testdir | |
parent | d4e4ecbb3793cd45b645471966c1ac703be52f4a (diff) |
patch 9.0.1796: Vim9 problems with null_objectsv9.0.1796
Problem: Vim9 problems with null_objects
Solution: Vim9 improve null_object usage
Fix "xvar == null", where xvar might have been assigned null_object.
Fix compilation failure: "var o2: C = null_object".
closes: #12890
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Ernie Rael <errael@raelity.com>
Diffstat (limited to 'src/testdir')
-rw-r--r-- | src/testdir/test_vim9_class.vim | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/src/testdir/test_vim9_class.vim b/src/testdir/test_vim9_class.vim index a650cc2509..2c6a501b45 100644 --- a/src/testdir/test_vim9_class.vim +++ b/src/testdir/test_vim9_class.vim @@ -337,7 +337,7 @@ def Test_object_not_set() var bg: Background # UNINITIALIZED echo Colorscheme.new(bg).GetBackground() END - v9.CheckScriptFailure(lines, 'E1012: Type mismatch; expected object<Background> but got object<Unknown>') + v9.CheckScriptFailure(lines, 'E1360:') # TODO: this should not give an error but be handled at runtime lines =<< trim END @@ -359,6 +359,46 @@ def Test_object_not_set() v9.CheckScriptFailure(lines, 'E1363:') enddef +def Test_null_object_assign_compare() + var lines =<< trim END + vim9script + + var nullo = null_object + def F(): any + return nullo + enddef + assert_equal('object<Unknown>', typename(F())) + + var o0 = F() + assert_true(o0 == null_object) + assert_true(o0 == null) + + var o1: any = nullo + assert_true(o1 == null_object) + assert_true(o1 == null) + + def G() + var x = null_object + enddef + + class C + endclass + var o2: C + assert_true(o2 == null_object) + assert_true(o2 == null) + + o2 = null_object + assert_true(o2 == null) + + o2 = C.new() + assert_true(o2 != null) + + o2 = null_object + assert_true(o2 == null) + END + v9.CheckScriptSuccess(lines) +enddef + def Test_class_member_initializer() var lines =<< trim END vim9script |