Mercurial > vim
comparison src/vim9execute.c @ 26470:ff0310e6f889 v8.2.3765
patch 8.2.3765: Vim9: cannot use a lambda for 'opfunc' and others
Commit: https://github.com/vim/vim/commit/dcb53be4418fe263a71c7738315241031df6c986
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Dec 9 14:23:43 2021 +0000
patch 8.2.3765: Vim9: cannot use a lambda for 'opfunc' and others
Problem: Vim9: cannot use a lambda for 'opfunc' and others.
Solution: Convert the lambda to a string.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 09 Dec 2021 15:30:04 +0100 |
parents | 568f93dcdc62 |
children | 4a1d2abc2016 |
comparison
equal
deleted
inserted
replaced
26469:8e3d1d2500bb | 26470:ff0310e6f889 |
---|---|
2334 } | 2334 } |
2335 break; | 2335 break; |
2336 | 2336 |
2337 // store option | 2337 // store option |
2338 case ISN_STOREOPT: | 2338 case ISN_STOREOPT: |
2339 { | 2339 case ISN_STOREFUNCOPT: |
2340 { | |
2341 char_u *opt_name = iptr->isn_arg.storeopt.so_name; | |
2342 int opt_flags = iptr->isn_arg.storeopt.so_flags; | |
2340 long n = 0; | 2343 long n = 0; |
2341 char_u *s = NULL; | 2344 char_u *s = NULL; |
2342 char *msg; | 2345 char *msg; |
2346 callback_T cb = {NULL, NULL, 0}; | |
2343 | 2347 |
2344 --ectx->ec_stack.ga_len; | 2348 --ectx->ec_stack.ga_len; |
2345 tv = STACK_TV_BOT(0); | 2349 tv = STACK_TV_BOT(0); |
2346 if (tv->v_type == VAR_STRING) | 2350 if (tv->v_type == VAR_STRING) |
2347 { | 2351 { |
2348 s = tv->vval.v_string; | 2352 s = tv->vval.v_string; |
2349 if (s == NULL) | 2353 if (s == NULL) |
2350 s = (char_u *)""; | 2354 s = (char_u *)""; |
2351 } | 2355 } |
2356 else if (iptr->isn_type == ISN_STOREFUNCOPT) | |
2357 { | |
2358 SOURCING_LNUM = iptr->isn_lnum; | |
2359 cb = get_callback(tv); | |
2360 if (cb.cb_name == NULL || *cb.cb_name == NUL) | |
2361 { | |
2362 clear_tv(tv); | |
2363 free_callback(&cb); | |
2364 goto on_error; | |
2365 } | |
2366 s = cb.cb_name; | |
2367 } | |
2352 else | 2368 else |
2353 // must be VAR_NUMBER, CHECKTYPE makes sure | 2369 // must be VAR_NUMBER, CHECKTYPE makes sure |
2354 n = tv->vval.v_number; | 2370 n = tv->vval.v_number; |
2355 msg = set_option_value(iptr->isn_arg.storeopt.so_name, | 2371 msg = set_option_value(opt_name, n, s, opt_flags); |
2356 n, s, iptr->isn_arg.storeopt.so_flags); | |
2357 clear_tv(tv); | 2372 clear_tv(tv); |
2358 if (msg != NULL) | 2373 if (msg != NULL) |
2359 { | 2374 { |
2360 SOURCING_LNUM = iptr->isn_lnum; | 2375 SOURCING_LNUM = iptr->isn_lnum; |
2361 emsg(_(msg)); | 2376 emsg(_(msg)); |
2362 goto on_error; | 2377 goto on_error; |
2363 } | 2378 } |
2379 if (cb.cb_name != NULL) | |
2380 free_callback(&cb); | |
2364 } | 2381 } |
2365 break; | 2382 break; |
2366 | 2383 |
2367 // store $ENV | 2384 // store $ENV |
2368 case ISN_STOREENV: | 2385 case ISN_STOREENV: |
5333 sref->sref_idx, | 5350 sref->sref_idx, |
5334 si->sn_name); | 5351 si->sn_name); |
5335 } | 5352 } |
5336 break; | 5353 break; |
5337 case ISN_STOREOPT: | 5354 case ISN_STOREOPT: |
5338 smsg("%s%4d STOREOPT &%s", pfx, current, | 5355 case ISN_STOREFUNCOPT: |
5356 smsg("%s%4d %s &%s", pfx, current, | |
5357 iptr->isn_type == ISN_STOREOPT ? "STOREOPT" : "STOREFUNCOPT", | |
5339 iptr->isn_arg.storeopt.so_name); | 5358 iptr->isn_arg.storeopt.so_name); |
5340 break; | 5359 break; |
5341 case ISN_STOREENV: | 5360 case ISN_STOREENV: |
5342 smsg("%s%4d STOREENV $%s", pfx, current, iptr->isn_arg.string); | 5361 smsg("%s%4d STOREENV $%s", pfx, current, iptr->isn_arg.string); |
5343 break; | 5362 break; |