comparison src/dict.c @ 23072:4b398a229b0b v8.2.2082

patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax Commit: https://github.com/vim/vim/commit/e0de171ecd2ff7acd56deda2cf81f0d13a69c803 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Dec 2 17:36:54 2020 +0100 patch 8.2.2082: Vim9: can still use the depricated #{} dict syntax Problem: Vim9: can still use the depricated #{} dict syntax. Solution: Remove support for #{} in Vim9 script. (closes https://github.com/vim/vim/issues/7406, closes https://github.com/vim/vim/issues/7405)
author Bram Moolenaar <Bram@vim.org>
date Wed, 02 Dec 2020 17:45:05 +0100
parents 5b2f97d10a8c
children 285cde4b8d0e
comparison
equal deleted inserted replaced
23071:20dac5998fa6 23072:4b398a229b0b
781 ga_append(&ga, NUL); 781 ga_append(&ga, NUL);
782 return (char_u *)ga.ga_data; 782 return (char_u *)ga.ga_data;
783 } 783 }
784 784
785 /* 785 /*
786 * Advance over a literal key, including "-". If the first character is not a
787 * literal key character then "key" is returned.
788 */
789 char_u *
790 skip_literal_key(char_u *key)
791 {
792 char_u *p;
793
794 for (p = key; ASCII_ISALNUM(*p) || *p == '_' || *p == '-'; ++p)
795 ;
796 return p;
797 }
798
799 /*
786 * Get the key for #{key: val} into "tv" and advance "arg". 800 * Get the key for #{key: val} into "tv" and advance "arg".
787 * Return FAIL when there is no valid key. 801 * Return FAIL when there is no valid key.
788 */ 802 */
789 static int 803 static int
790 get_literal_key(char_u **arg, typval_T *tv) 804 get_literal_key(char_u **arg, typval_T *tv)
791 { 805 {
792 char_u *p; 806 char_u *p = skip_literal_key(*arg);
793 807
794 if (!ASCII_ISALNUM(**arg) && **arg != '_' && **arg != '-') 808 if (p == *arg)
795 return FAIL; 809 return FAIL;
796
797 for (p = *arg; ASCII_ISALNUM(*p) || *p == '_' || *p == '-'; ++p)
798 ;
799 tv->v_type = VAR_STRING; 810 tv->v_type = VAR_STRING;
800 tv->vval.v_string = vim_strnsave(*arg, p - *arg); 811 tv->vval.v_string = vim_strnsave(*arg, p - *arg);
801 812
802 *arg = p; 813 *arg = p;
803 return OK; 814 return OK;
849 tv.v_type = VAR_UNKNOWN; 860 tv.v_type = VAR_UNKNOWN;
850 861
851 *arg = skipwhite_and_linebreak(*arg + 1, evalarg); 862 *arg = skipwhite_and_linebreak(*arg + 1, evalarg);
852 while (**arg != '}' && **arg != NUL) 863 while (**arg != '}' && **arg != NUL)
853 { 864 {
854 char_u *p = to_name_end(*arg, FALSE); 865 int has_bracket = vim9script && **arg == '[';
855 866
856 if (literal || (vim9script && *p == ':')) 867 if (literal || (vim9script && !has_bracket))
857 { 868 {
858 if (get_literal_key(arg, &tvkey) == FAIL) 869 if (get_literal_key(arg, &tvkey) == FAIL)
859 goto failret; 870 goto failret;
860 } 871 }
861 else 872 else
862 { 873 {
863 int has_bracket = vim9script && **arg == '[';
864
865 if (has_bracket) 874 if (has_bracket)
866 *arg = skipwhite(*arg + 1); 875 *arg = skipwhite(*arg + 1);
867 if (eval1(arg, &tvkey, evalarg) == FAIL) // recursive! 876 if (eval1(arg, &tvkey, evalarg) == FAIL) // recursive!
868 goto failret; 877 goto failret;
869 if (has_bracket) 878 if (has_bracket)