Patch 8.2.3359
Problem:    Vim9: error for type when variable is not set.
Solution:   Give a specific error for a NULL function. (closes #8773)
Files:      src/vim9type.c, src/errors.h, src/testdir/test_vim9_func.vim


*** ../vim-8.2.3358/src/vim9type.c      2021-08-09 22:22:23.160468830 +0200
--- src/vim9type.c      2021-08-19 20:28:44.807618920 +0200
***************
*** 461,466 ****
--- 461,476 ----
      type_T    *actual_type;
      int               res = FAIL;
  
+     // For some values there is no type, assume an error will be given later
+     // for an invalid value.
+     if ((actual_tv->v_type == VAR_FUNC && actual_tv->vval.v_string == NULL)
+           || (actual_tv->v_type == VAR_PARTIAL
+                                        && actual_tv->vval.v_partial == NULL))
+     {
+       emsg(_(e_function_reference_is_not_set));
+       return FAIL;
+     }
+ 
      ga_init2(&type_list, sizeof(type_T *), 10);
      actual_type = typval2type(actual_tv, get_copyID(), &type_list, TRUE);
      if (actual_type != NULL)
*** ../vim-8.2.3358/src/errors.h        2021-08-15 13:49:38.126905573 +0200
--- src/errors.h        2021-08-19 20:27:26.951794052 +0200
***************
*** 652,654 ****
--- 652,656 ----
        INIT(= N_("E1233: exists_compiled() can only be used in a :def 
function"));
  EXTERN char e_legacy_must_be_followed_by_command[]
        INIT(= N_("E1234: legacy must be followed by a command"));
+ EXTERN char e_function_reference_is_not_set[]
+       INIT(= N_("E1235: Function reference is not set"));
*** ../vim-8.2.3358/src/testdir/test_vim9_func.vim      2021-08-15 
19:28:01.808558478 +0200
--- src/testdir/test_vim9_func.vim      2021-08-19 20:32:27.691116587 +0200
***************
*** 2696,2701 ****
--- 2696,2710 ----
        assert_equal('ooooo', RepeatFunc(5))
    END
    CheckDefAndScriptSuccess(lines)
+ 
+   lines =<< trim END
+       vim9script
+       def Foo(Parser: any)
+       enddef
+       var Expr: func(dict<any>): dict<any>
+       const Call = Foo(Expr)
+   END
+   CheckScriptFailure(lines, 'E1235:')
  enddef
  
  def Test_cmd_modifier()
*** ../vim-8.2.3358/src/version.c       2021-08-17 23:44:50.839149609 +0200
--- src/version.c       2021-08-19 20:23:03.524384522 +0200
***************
*** 757,758 ****
--- 757,760 ----
  {   /* Add new patch number below this line */
+ /**/
+     3359,
  /**/

-- 
A parent can be arrested if his child cannot hold back a burp during a church
service.
                [real standing law in Nebraska, United States of America]

 /// Bram Moolenaar -- [email protected] -- 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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202108191909.17JJ94sj654222%40masaka.moolenaar.net.

Raspunde prin e-mail lui