@@ -386,6 +386,26 @@ variable_exists(char_u *name, size_t len, cctx_T *cctx)
386386 || find_imported (name , len , cctx ) != NULL ;
387387}
388388
389+ /*
390+ * Return TRUE if "name" is a local variable, argument, script variable,
391+ * imported or function.
392+ */
393+ static int
394+ item_exists (char_u * name , size_t len , cctx_T * cctx )
395+ {
396+ int is_global ;
397+
398+ if (variable_exists (name , len , cctx ))
399+ return TRUE;
400+
401+ // Find a function, so that a following "->" works. Skip "g:" before a
402+ // function name.
403+ // Do not check for an internal function, since it might also be a
404+ // valid command, such as ":split" versuse "split()".
405+ is_global = (name [0 ] == 'g' && name [1 ] == ':' );
406+ return find_func (is_global ? name + 2 : name , is_global , cctx ) != NULL ;
407+ }
408+
389409/*
390410 * Check if "p[len]" is already defined, either in script "import_sid" or in
391411 * compilation context "cctx". "cctx" is NULL at the script level.
@@ -728,7 +748,7 @@ get_compare_isn(exprtype_T exprtype, vartype_T type1, vartype_T type2)
728748 }
729749 else if (type1 == VAR_ANY || type2 == VAR_ANY
730750 || ((type1 == VAR_NUMBER || type1 == VAR_FLOAT )
731- && (type2 == VAR_NUMBER || type2 == VAR_FLOAT )))
751+ && (type2 == VAR_NUMBER || type2 == VAR_FLOAT )))
732752 isntype = ISN_COMPAREANY ;
733753
734754 if ((exprtype == EXPR_IS || exprtype == EXPR_ISNOT )
@@ -8399,8 +8419,7 @@ compile_def_function(
83998419 }
84008420 }
84018421 p = find_ex_command (& ea , NULL , starts_with_colon ? NULL
8402- : (int (* )(char_u * , size_t , cctx_T * ))variable_exists ,
8403- & cctx );
8422+ : (int (* )(char_u * , size_t , cctx_T * ))item_exists , & cctx );
84048423
84058424 if (p == NULL )
84068425 {
0 commit comments