Mercurial > vim
comparison src/testdir/test_vim9_assign.vim @ 22906:5ff7125e81fc v8.2.2000
patch 8.2.2000: Vim9: dict.key assignment not implemented yet
Commit: https://github.com/vim/vim/commit/fc74d03e7694bac3b50d8d6b6b78b40a71818744
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Nov 16 22:11:49 2020 +0100
patch 8.2.2000: Vim9: dict.key assignment not implemented yet
Problem: Vim9: dict.key assignment not implemented yet.
Solution: Implement dict.key assignment. (closes https://github.com/vim/vim/issues/7312)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 16 Nov 2020 22:15:03 +0100 |
parents | 3e0f909ca1f2 |
children | b98003d73150 |
comparison
equal
deleted
inserted
replaced
22905:3e3b02c8ca00 | 22906:5ff7125e81fc |
---|---|
406 var dict4: dict<any> = #{one: 1, two: '2'} | 406 var dict4: dict<any> = #{one: 1, two: '2'} |
407 var dict5: dict<blob> = #{one: 0z01, two: 0z02} | 407 var dict5: dict<blob> = #{one: 0z01, two: 0z02} |
408 | 408 |
409 # overwrite | 409 # overwrite |
410 dict3['key'] = 'another' | 410 dict3['key'] = 'another' |
411 assert_equal(dict3, #{key: 'another'}) | |
412 dict3.key = 'yet another' | |
413 assert_equal(dict3, #{key: 'yet another'}) | |
414 | |
415 var lines =<< trim END | |
416 var dd = #{one: 1} | |
417 dd.one) = 2 | |
418 END | |
419 CheckDefFailure(lines, 'E15:', 2) | |
411 | 420 |
412 # empty key can be used | 421 # empty key can be used |
413 var dd = {} | 422 var dd = {} |
414 dd[""] = 6 | 423 dd[""] = 6 |
415 assert_equal({'': 6}, dd) | 424 assert_equal({'': 6}, dd) |
416 | 425 |
417 # type becomes dict<any> | 426 # type becomes dict<any> |
418 var somedict = rand() > 0 ? #{a: 1, b: 2} : #{a: 'a', b: 'b'} | 427 var somedict = rand() > 0 ? #{a: 1, b: 2} : #{a: 'a', b: 'b'} |
419 | 428 |
420 # assignment to script-local dict | 429 # assignment to script-local dict |
421 var lines =<< trim END | 430 lines =<< trim END |
422 vim9script | 431 vim9script |
423 var test: dict<any> = {} | 432 var test: dict<any> = {} |
424 def FillDict(): dict<any> | 433 def FillDict(): dict<any> |
425 test['a'] = 43 | 434 test['a'] = 43 |
426 return test | 435 return test |