Patch 8.2.4530
Problem:    Making comparison with null work changes legacy behavior.
Solution:   Only use the better comparison in Vim9 script. (closes #9910)
Files:      src/typval.c, src/testdir/test_expr.vim


*** ../vim-8.2.4529/src/typval.c        2022-03-02 13:13:26.475857972 +0000
--- src/typval.c        2022-03-09 11:50:05.358375030 +0000
***************
*** 1381,1387 ****
  }
  
  /*
!  * Compare v:null/v:none with another type.  Return TRUE if the value is NULL.
   */
      int
  typval_compare_null(typval_T *tv1, typval_T *tv2)
--- 1381,1387 ----
  }
  
  /*
!  * Compare v:null with another type.  Return TRUE if the value is NULL.
   */
      int
  typval_compare_null(typval_T *tv1, typval_T *tv2)
***************
*** 1417,1422 ****
--- 1417,1425 ----
            default: break;
        }
      }
+     if (!in_vim9script())
+       return FALSE;  // backwards compatible
+ 
      semsg(_(e_cannot_compare_str_with_str),
                         vartype_name(tv1->v_type), vartype_name(tv2->v_type));
      return MAYBE;
*** ../vim-8.2.4529/src/testdir/test_expr.vim   2022-03-08 13:18:10.813020777 
+0000
--- src/testdir/test_expr.vim   2022-03-09 11:52:51.305921959 +0000
***************
*** 181,186 ****
--- 181,218 ----
    call v9.CheckScriptFailure(lines, 'E121: Undefined variable: null_list')
  endfunc
  
+ func Test_compare_with_null()
+   let s:value = v:null
+   call assert_true(s:value == v:null)
+   let s:value = v:true
+   call assert_false(s:value == v:null)
+   let s:value = v:none
+   call assert_false(s:value == v:null)
+   let s:value = 0
+   call assert_true(s:value == v:null)
+   if has('float')
+     let s:value = 0.0
+     call assert_true(s:value == v:null)
+   endif
+   let s:value = ''
+   call assert_false(s:value == v:null)
+   let s:value = 0z
+   call assert_false(s:value == v:null)
+   let s:value = []
+   call assert_false(s:value == v:null)
+   let s:value = {}
+   call assert_false(s:value == v:null)
+   let s:value = function('len')
+   call assert_false(s:value == v:null)
+   if has('job')
+     let s:value = test_null_job()
+     call assert_true(s:value == v:null)
+     let s:value = test_null_channel()
+     call assert_true(s:value == v:null)
+   endif
+   unlet s:value
+ endfunc
+ 
  func Test_setreg_null_list()
    let lines =<< trim END
        call setreg('x', test_null_list())
*** ../vim-8.2.4529/src/version.c       2022-03-08 19:43:51.692198946 +0000
--- src/version.c       2022-03-09 11:36:08.368674934 +0000
***************
*** 752,753 ****
--- 752,755 ----
  {   /* Add new patch number below this line */
+ /**/
+     4530,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
213. Your kids start referring to you as "that guy in front of the monitor."

 /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20220309115750.770931C0D0A%40moolenaar.net.

Raspunde prin e-mail lui