comparison src/vim9compile.c @ 19336:1cd6eab65ce0 v8.2.0226

patch 8.2.0226: compiling for loop not tested Commit: https://github.com/vim/vim/commit/04d0522046e79d0e13c1317ad34bf228722ec728 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Feb 6 22:06:54 2020 +0100 patch 8.2.0226: compiling for loop not tested Problem: Compiling for loop not tested. Solution: Add a test. Make variable initialization work for more types.
author Bram Moolenaar <Bram@vim.org>
date Thu, 06 Feb 2020 22:15:03 +0100
parents d6e8a9e80be4
children 8ff84bc1c89b
comparison
equal deleted inserted replaced
19335:fcd98c9a13e4 19336:1cd6eab65ce0
3425 goto theend; 3425 goto theend;
3426 } 3426 }
3427 else 3427 else
3428 { 3428 {
3429 // variables are always initialized 3429 // variables are always initialized
3430 // TODO: support more types
3431 if (ga_grow(instr, 1) == FAIL) 3430 if (ga_grow(instr, 1) == FAIL)
3432 goto theend; 3431 goto theend;
3433 if (type->tt_type == VAR_STRING) 3432 switch (type->tt_type)
3434 generate_PUSHS(cctx, vim_strsave((char_u *)"")); 3433 {
3435 else 3434 case VAR_BOOL:
3436 generate_PUSHNR(cctx, 0); 3435 generate_PUSHBOOL(cctx, VVAL_FALSE);
3436 break;
3437 case VAR_SPECIAL:
3438 generate_PUSHSPEC(cctx, VVAL_NONE);
3439 break;
3440 case VAR_FLOAT:
3441 #ifdef FEAT_FLOAT
3442 generate_PUSHF(cctx, 0.0);
3443 #endif
3444 break;
3445 case VAR_STRING:
3446 generate_PUSHS(cctx, NULL);
3447 break;
3448 case VAR_BLOB:
3449 generate_PUSHBLOB(cctx, NULL);
3450 break;
3451 case VAR_FUNC:
3452 // generate_PUSHS(cctx, NULL); TODO
3453 break;
3454 case VAR_PARTIAL:
3455 // generate_PUSHS(cctx, NULL); TODO
3456 break;
3457 case VAR_LIST:
3458 generate_NEWLIST(cctx, 0);
3459 break;
3460 case VAR_DICT:
3461 generate_NEWDICT(cctx, 0);
3462 break;
3463 case VAR_JOB:
3464 // generate_PUSHS(cctx, NULL); TODO
3465 break;
3466 case VAR_CHANNEL:
3467 // generate_PUSHS(cctx, NULL); TODO
3468 break;
3469 case VAR_NUMBER:
3470 case VAR_UNKNOWN:
3471 case VAR_VOID:
3472 generate_PUSHNR(cctx, 0);
3473 break;
3474 }
3437 } 3475 }
3438 3476
3439 if (oplen > 0 && *op != '=') 3477 if (oplen > 0 && *op != '=')
3440 { 3478 {
3441 type_T *expected = &t_number; 3479 type_T *expected = &t_number;