diff src/userfunc.c @ 25042:3f39b6b73019 v8.2.3058

patch 8.2.3058: Vim9: cannot use ternary operator in parenthesis Commit: https://github.com/vim/vim/commit/015cf103115f9a0380ae3e3e85a77792cfe87d49 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Jun 26 21:52:02 2021 +0200 patch 8.2.3058: Vim9: cannot use ternary operator in parenthesis Problem: Vim9: cannot use ternary operator in parenthesis. Solution: Do not use "==" for a default argument value. (closes https://github.com/vim/vim/issues/8462)
author Bram Moolenaar <Bram@vim.org>
date Sat, 26 Jun 2021 22:00:05 +0200
parents efdb9608cc11
children a9a21631c090
line wrap: on
line diff
--- a/src/userfunc.c
+++ b/src/userfunc.c
@@ -266,13 +266,18 @@ get_function_args(
 	}
 	else
 	{
+	    char_u *np;
+
 	    arg = p;
 	    p = one_function_arg(p, newargs, argtypes, types_optional,
 							 evalarg, FALSE, skip);
 	    if (p == arg)
 		break;
 
-	    if (*skipwhite(p) == '=' && default_args != NULL)
+	    // Recognize " = expr" but not " == expr".  A lambda can have
+	    // "(a = expr" but "(a == expr" is not a lambda.
+	    np = skipwhite(p);
+	    if (*np == '=' && np[1] != '=' && default_args != NULL)
 	    {
 		typval_T	rettv;