diff src/testdir/test_vim9_disassemble.vim @ 22196:d835f2fdfcfc v8.2.1647

patch 8.2.1647: Vim9: result of expression with && and || is not a bool Commit: https://github.com/vim/vim/commit/4ed124cc6c0c55385c3b2fed9f9357baf42edbcc Author: Bram Moolenaar <Bram@vim.org> Date: Wed Sep 9 20:03:46 2020 +0200 patch 8.2.1647: Vim9: result of expression with && and || is not a bool Problem: Vim9: result of expression with && and || cannot be assigned to a bool variable. Solution: Add the TTFLAG_BOOL_OK flag and convert the value if needed.
author Bram Moolenaar <Bram@vim.org>
date Wed, 09 Sep 2020 20:15:03 +0200
parents 6941d3205be9
children 6b385c2b9ff5
line wrap: on
line diff
--- a/src/testdir/test_vim9_disassemble.vim
+++ b/src/testdir/test_vim9_disassemble.vim
@@ -1199,6 +1199,29 @@ def Test_disassemble_invert_bool()
   assert_equal(true, InvertBool())
 enddef
 
+def ReturnBool(): bool
+  let var: bool = "no" && [] || 123
+  return var
+enddef
+
+def Test_disassemble_return_bool()
+  let instr = execute('disassemble ReturnBool')
+  assert_match('ReturnBool\_s*' ..
+        'let var: bool = "no" && \[\] || 123\_s*' ..
+        '0 PUSHS "no"\_s*' ..
+        '1 JUMP_AND_KEEP_IF_FALSE -> 3\_s*' ..
+        '2 NEWLIST size 0\_s*' ..
+        '3 JUMP_AND_KEEP_IF_TRUE -> 5\_s*' ..
+        '4 PUSHNR 123\_s*' ..
+        '5 2BOOL (!!val)\_s*' ..
+        '\d STORE $0\_s*' ..
+        'return var\_s*' ..
+        '\d LOAD $0\_s*' ..   
+        '\d RETURN',
+        instr)
+  assert_equal(true, InvertBool())
+enddef
+
 def Test_disassemble_compare()
   let cases = [
         ['true == isFalse', 'COMPAREBOOL =='],