Mercurial > vim
diff src/vim9compile.c @ 24158:93e69703a290 v8.2.2620
patch 8.2.2620: Vim9: Using #{ for a dictionary gives strange errors
Commit: https://github.com/vim/vim/commit/4b3e1964d85a25ac7b2202094d1abf27ab93cc23
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Mar 18 21:37:55 2021 +0100
patch 8.2.2620: Vim9: Using #{ for a dictionary gives strange errors
Problem: Vim9: Using #{ for a dictionary gives strange errors.
Solution: Give an error when using #{ for a comment after a command.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 18 Mar 2021 21:45:05 +0100 |
parents | 6e8f49a4a193 |
children | c20e763bc73c |
line wrap: on
line diff
--- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -1546,7 +1546,7 @@ generate_FUNCREF(cctx_T *cctx, ufunc_T * isn->isn_arg.funcref.fr_func = ufunc->uf_dfunc_idx; cctx->ctx_has_closure = 1; - // if the referenced function is a closure, it may use items further up in + // If the referenced function is a closure, it may use items further up in // the nested context, including this one. if (ufunc->uf_flags & FC_CLOSURE) cctx->ctx_ufunc->uf_flags |= FC_CLOSURE; @@ -2401,6 +2401,8 @@ peek_next_line_from_context(cctx_T *cctx if (line != NULL) { p = skipwhite(line); + if (vim9_bad_comment(p)) + return NULL; if (*p != NUL && !vim9_comment_start(p)) return p; } @@ -2465,6 +2467,8 @@ next_line_from_context(cctx_T *cctx, int may_get_next_line(char_u *whitep, char_u **arg, cctx_T *cctx) { *arg = skipwhite(whitep); + if (vim9_bad_comment(*arg)) + return FAIL; if (**arg == NUL || (VIM_ISWHITE(*whitep) && vim9_comment_start(*arg))) { char_u *next = next_line_from_context(cctx, TRUE); @@ -4277,10 +4281,13 @@ compile_expr7( if (!eval_isnamec1(**arg)) { - if (ends_excmd(*skipwhite(*arg))) - semsg(_(e_empty_expression_str), *arg); - else - semsg(_(e_name_expected_str), *arg); + if (!vim9_bad_comment(*arg)) + { + if (ends_excmd(*skipwhite(*arg))) + semsg(_(e_empty_expression_str), *arg); + else + semsg(_(e_name_expected_str), *arg); + } return FAIL; } @@ -8297,6 +8304,8 @@ compile_def_function( semsg(_(e_trailing_arg), line); goto erret; } + else if (line != NULL && vim9_bad_comment(skipwhite(line))) + goto erret; else { line = next_line_from_context(&cctx, FALSE);