Mercurial > vim
comparison src/vim9compile.c @ 20397:c225be44692a v8.2.0753
patch 8.2.0753: Vim9: expressions are evaluated in the discovery phase
Commit: https://github.com/vim/vim/commit/32e351179eacfc84f64cd5029e221582d400bb38
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu May 14 22:41:15 2020 +0200
patch 8.2.0753: Vim9: expressions are evaluated in the discovery phase
Problem: Vim9: expressions are evaluated in the discovery phase.
Solution: Bail out if an expression is not a constant. Require a type for
declared constants.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 14 May 2020 22:45:04 +0200 |
parents | fad124c0e349 |
children | d54dfb5f12db |
comparison
equal
deleted
inserted
replaced
20396:89228c88b5c4 | 20397:c225be44692a |
---|---|
2867 | 2867 |
2868 if (p == arg && *arg == '[') | 2868 if (p == arg && *arg == '[') |
2869 { | 2869 { |
2870 | 2870 |
2871 // Can be "[1, 2, 3]->Func()". | 2871 // Can be "[1, 2, 3]->Func()". |
2872 if (get_list_tv(&p, &rettv, FALSE, FALSE) == FAIL) | 2872 if (get_list_tv(&p, &rettv, 0, FALSE) == FAIL) |
2873 p = arg; | 2873 p = arg; |
2874 } | 2874 } |
2875 else if (p == arg && *arg == '#' && arg[1] == '{') | 2875 else if (p == arg && *arg == '#' && arg[1] == '{') |
2876 { | 2876 { |
2877 // Can be "#{a: 1}->Func()". | 2877 // Can be "#{a: 1}->Func()". |
2878 ++p; | 2878 ++p; |
2879 if (eval_dict(&p, &rettv, FALSE, TRUE) == FAIL) | 2879 if (eval_dict(&p, &rettv, 0, TRUE) == FAIL) |
2880 p = arg; | 2880 p = arg; |
2881 } | 2881 } |
2882 else if (p == arg && *arg == '{') | 2882 else if (p == arg && *arg == '{') |
2883 { | 2883 { |
2884 int ret = get_lambda_tv(&p, &rettv, FALSE); | 2884 int ret = get_lambda_tv(&p, &rettv, FALSE); |
2885 | 2885 |
2886 // Can be "{x -> ret}()". | 2886 // Can be "{x -> ret}()". |
2887 // Can be "{'a': 1}->Func()". | 2887 // Can be "{'a': 1}->Func()". |
2888 if (ret == NOTDONE) | 2888 if (ret == NOTDONE) |
2889 ret = eval_dict(&p, &rettv, FALSE, FALSE); | 2889 ret = eval_dict(&p, &rettv, 0, FALSE); |
2890 if (ret != OK) | 2890 if (ret != OK) |
2891 p = arg; | 2891 p = arg; |
2892 } | 2892 } |
2893 | 2893 |
2894 return p; | 2894 return p; |