patch 9.0.1897: Vim9: confusing error with .= in compiled functions
Commit:
https://github.com/vim/vim/commit/504543f98be2ddb6d49ea2f7e996112868fc54ed
Author: Christian Brabandt <[email protected]>
Date: Mon Sep 11 20:08:50 2023 +0200
patch 9.0.1897: Vim9: confusing error with .= in compiled functions
Problem: Vim9: confusing error with .= in compiled functions
Solution: Check in error condition, if .= was attempted and in that case
give a different error message.
closes: #12972
closes: #13066
Signed-off-by: Christian Brabandt <[email protected]>
diff --git a/src/testdir/test_vim9_cmd.vim b/src/testdir/test_vim9_cmd.vim
index 0fe6e7ca0..a9e10e797 100644
--- a/src/testdir/test_vim9_cmd.vim
+++ b/src/testdir/test_vim9_cmd.vim
@@ -79,6 +79,25 @@ def Test_vim9cmd()
legacy echo version
END
v9.CheckScriptSuccess(lines)
+
+ lines =<< trim END
+ vim9script
+ def Func()
+ var d: dict<string>
+ d.k .= ''
+ enddef
+ defcompile
+ END
+ v9.CheckScriptFailure(lines, 'E985:')
+ lines =<< trim END
+ vim9script
+ def Func()
+ var d: dict<string>
+ d.k ,= ''
+ enddef
+ defcompile
+ END
+ v9.CheckScriptFailure(lines, 'E1017:')
enddef
def Test_defcompile_fails()
diff --git a/src/version.c b/src/version.c
index 937f8b8ab..aaa50da4b 100644
--- a/src/version.c
+++ b/src/version.c
@@ -699,6 +699,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 1897,
/**/
1896,
/**/
diff --git a/src/vim9compile.c b/src/vim9compile.c
index 7d24f21c8..cc4aa4638 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -1669,7 +1669,14 @@ compile_lhs(
{
if (is_decl)
{
- semsg(_(e_variable_already_declared_str), lhs->lhs_name);
+ // if we come here with what looks like an assignment like
.=
+ // but which has been reject by assignment_len() from
may_compile_assignment
+ // give a better error message
+ char_u *p = skipwhite(lhs->lhs_end);
+ if (p[0] == '.' && p[1] == '=')
+
emsg(_(e_dot_equal_not_supported_with_script_version_two));
+ else
+ semsg(_(e_variable_already_declared_str),
lhs->lhs_name);
return FAIL;
}
}
--
--
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/E1qflRC-007tOO-20%40256bit.org.