patch 8.1.0019: error when defining a Lambda with index of a function result
Problem: Error when defining a Lambda with index of a function result.
Solution: When not evaluating an expression and skipping a function call,
set the return value to VAR_UNKNOWN.
diff --git a/src/userfunc.c b/src/userfunc.c
index f9b0e81..0811268 100644
--- a/src/userfunc.c
+++ b/src/userfunc.c
@@ -1349,8 +1349,16 @@
}
- /* execute the function if no errors detected and executing */
- if (evaluate && error == ERROR_NONE)
+ /*
+ * Execute the function if executing and no errors were detected.
+ */
+ if (!evaluate)
+ {
+ // Not evaluating, which means the return value is unknown. This
+ // matters for giving error messages.
+ rettv->v_type = VAR_UNKNOWN;
+ }
+ else if (error == ERROR_NONE)
{
char_u *rfname = fname;