Mercurial > vim
diff src/vim9compile.c @ 33466:3de472480e91 v9.0.1986
patch 9.0.1986: Vim9: accepting type-annotations
Commit: https://github.com/vim/vim/commit/b5a0719cb7abf51b0540df527cb9738a3ccf0d37
Author: Yegappan Lakshmanan <yegappan@yahoo.com>
Date: Thu Oct 5 20:14:43 2023 +0200
patch 9.0.1986: Vim9: accepting type-annotations
Problem: Vim9: accepting type-annotations
Solution: Reject type annotations outside of declarations.
closes: #13267
closes: #13283
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Thu, 05 Oct 2023 20:30:08 +0200 |
parents | 508dfc0c261c |
children | bff8ac203a22 |
line wrap: on
line diff
--- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -1737,11 +1737,14 @@ compile_lhs( if (is_decl) { // if we come here with what looks like an assignment like - // .= but which has been reject by assignment_len() from + // .= but which has been rejected 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 if (p[0] == ':') + // type specified in a non-var assignment + semsg(_(e_trailing_characters_str), p); else semsg(_(e_variable_already_declared_str), lhs->lhs_name); return FAIL;