patch 9.1.2101: Vim9: more truthiness issues

Commit: 
https://github.com/vim/vim/commit/a7d195415b31ca6168501cac3506e65beb484ada
Author: Yegappan Lakshmanan <[email protected]>
Date:   Tue Jan 20 19:46:33 2026 +0000

    patch 9.1.2101: Vim9: more truthiness issues
    
    Problem:  Vim9: more truthiness issues
              (kennypete)
    Solution: Class, enum and typealias cannot be used with the falsy
              operator (Yegappan Lakshmanan)
    
    related: #19213
    fixes:   #19173
    closes:  #19216
    
    Signed-off-by: Yegappan Lakshmanan <[email protected]>
    Signed-off-by: Christian Brabandt <[email protected]>

diff --git a/src/testdir/test_vim9_expr.vim b/src/testdir/test_vim9_expr.vim
index 87b821638..b66372884 100644
--- a/src/testdir/test_vim9_expr.vim
+++ b/src/testdir/test_vim9_expr.vim
@@ -263,6 +263,67 @@ def Test_expr1_falsy()
   END
   v9.CheckSourceScriptSuccess(lines)
 
+  # class cannot be used with the falsy operator
+  lines =<< trim END
+    vim9script
+    class A
+    endclass
+    echo A ?? 'falsy'
+  END
+  v9.CheckSourceScriptFailure(lines, 'E1405: Class "A" cannot be used as a 
value')
+
+  lines =<< trim END
+    vim9script
+    class B
+    endclass
+    echo !B
+  END
+  v9.CheckSourceScriptFailure(lines, 'E1405: Class "B" cannot be used as a 
value')
+
+  lines =<< trim END
+    vim9script
+    echo null_class ?? 'falsy'
+  END
+  v9.CheckSourceScriptFailure(lines, 'E1405: Class "" cannot be used as a 
value')
+
+  lines =<< trim END
+    vim9script
+    echo !null_class
+  END
+  v9.CheckSourceScriptFailure(lines, 'E1405: Class "" cannot be used as a 
value')
+
+  # enum cannot be used with the falsy operator
+  lines =<< trim END
+    vim9script
+    enum E1
+    endenum
+    echo E1 ?? 'falsy'
+  END
+  v9.CheckSourceScriptFailure(lines, 'E1421: Enum "E1" cannot be used as a 
value')
+
+  lines =<< trim END
+    vim9script
+    enum E2
+    endenum
+    echo !E2
+  END
+  v9.CheckSourceScriptFailure(lines, 'E1421: Enum "E2" cannot be used as a 
value')
+
+  # typealias cannot be used with the falsy operator
+  lines =<< trim END
+    vim9script
+    type T1 = list<bool>
+    echo T1 ?? 'falsy'
+  END
+  v9.CheckSourceScriptFailure(lines, 'E1403: Type alias "T1" cannot be used as 
a value')
+
+  lines =<< trim END
+    vim9script
+    type T2 = list<bool>
+    echo !T2
+  END
+  v9.CheckSourceScriptFailure(lines, 'E1403: Type alias "T2" cannot be used as 
a value')
+
   var msg = "White space required before and after '??'"
   call v9.CheckDefAndScriptFailure(["var x = 1?? 'one' : 'two'"], msg, 1)
   call v9.CheckDefAndScriptFailure(["var x = 1 ??'one' : 'two'"], msg, 1)
diff --git a/src/version.c b/src/version.c
index 61720c936..d6644bf10 100644
--- a/src/version.c
+++ b/src/version.c
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2101,
 /**/
     2100,
 /**/
diff --git a/src/vim9execute.c b/src/vim9execute.c
index 9763cd95b..bdea74f66 100644
--- a/src/vim9execute.c
+++ b/src/vim9execute.c
@@ -8131,12 +8131,15 @@ tv2bool(typval_T *tv)
        case VAR_OBJECT:
            return tv->vval.v_object != NULL;
 
+       case VAR_CLASS:
+       case VAR_TYPEALIAS:
+           check_typval_is_value(tv);
+           break;
+
        case VAR_UNKNOWN:
        case VAR_ANY:
        case VAR_VOID:
        case VAR_INSTR:
-       case VAR_CLASS:
-       case VAR_TYPEALIAS:
            break;
     }
     return FALSE;

-- 
-- 
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 [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/vim_dev/E1viHtT-005JGm-Cw%40256bit.org.

Raspunde prin e-mail lui