]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.2165: Vim9: assignment to dict member does not work v8.2.2165
authorBram Moolenaar <Bram@vim.org>
Sat, 19 Dec 2020 21:10:13 +0000 (22:10 +0100)
committerBram Moolenaar <Bram@vim.org>
Sat, 19 Dec 2020 21:10:13 +0000 (22:10 +0100)
Problem:    Vim9: assignment to dict member does not work.
Solution:   Fix recognizing dict member. (closes #7484)

src/eval.c
src/evalvars.c
src/ex_docmd.c
src/version.c
src/vim.h

index 496e20875624e16acd27cf44933b31b6a39eff96..f84491e043a6eae1fc3e6afa295ca3a8d0143730 100644 (file)
@@ -874,6 +874,13 @@ get_lval(
     if (v == NULL)
        return NULL;
 
+    if (in_vim9script() && (flags & GLV_NO_DECL) == 0)
+    {
+       if (!quiet)
+           semsg(_(e_variable_already_declared), lp->ll_name);
+       return NULL;
+    }
+
     /*
      * Loop until no more [idx] or .key is following.
      */
index 654eeff23086c957ffbf5155e8c1e17a5587f0a8..572e5d5567a82fbef2874819590a7f8c4f6b6aaa 100644 (file)
@@ -1464,7 +1464,8 @@ ex_let_one(
     {
        lval_T  lv;
 
-       p = get_lval(arg, tv, &lv, FALSE, FALSE, 0, FNE_CHECK_START);
+       p = get_lval(arg, tv, &lv, FALSE, FALSE,
+               (flags & ASSIGN_NO_DECL) ? GLV_NO_DECL : 0, FNE_CHECK_START);
        if (p != NULL && lv.ll_name != NULL)
        {
            if (endchars != NULL && vim_strchr(endchars,
index 152eda6c6c2b96b1d4020de80aeedd557304e30a..95d4dd16b7f9efa7eb7a5283daa9b185b7413f84 100644 (file)
@@ -3332,6 +3332,8 @@ find_ex_command(
 
                // When followed by "=" or "+=" then it is an assignment.
                ++emsg_silent;
+               if (*after == '.')
+                   after = skipwhite(after + 1);
                if (skip_expr(&after, NULL) == OK)
                    after = skipwhite(after);
                else
index a97037d510686065894cd9e9b6e48fdc3c10c166..fe06be04973da30a20a067c6f4f5be58e82a2027 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2165,
 /**/
     2164,
 /**/
index d6c1f46e14f6e8fbbf4082657cee8a231d32fa73..ebd7db441e51b449203c948906f7734147499b90 100644 (file)
--- a/src/vim.h
+++ b/src/vim.h
@@ -2536,16 +2536,18 @@ typedef enum {
 #define COPYID_MASK (~0x1)
 
 // Values for trans_function_name() argument:
-#define TFN_INT                1       // internal function name OK
-#define TFN_QUIET      2       // no error messages
-#define TFN_NO_AUTOLOAD        4       // do not use script autoloading
-#define TFN_NO_DEREF   8       // do not dereference a Funcref
-#define TFN_READ_ONLY  16      // will not change the var
+#define TFN_INT                0x01    // internal function name OK
+#define TFN_QUIET      0x02    // no error messages
+#define TFN_NO_AUTOLOAD        0x04    // do not use script autoloading
+#define TFN_NO_DEREF   0x08    // do not dereference a Funcref
+#define TFN_READ_ONLY  0x10    // will not change the var
+#define TFN_NO_DECL    0x20    // only used for GLV_NO_DECL
 
 // Values for get_lval() flags argument:
 #define GLV_QUIET      TFN_QUIET       // no error messages
 #define GLV_NO_AUTOLOAD        TFN_NO_AUTOLOAD // do not use script autoloading
 #define GLV_READ_ONLY  TFN_READ_ONLY   // will not change the var
+#define GLV_NO_DECL    TFN_NO_DECL     // assignment without :var or :let
 
 #define DO_NOT_FREE_CNT 99999  // refcount for dict or list that should not
                                // be freed.