Mercurial > vim
comparison src/testdir/test_vim9_builtin.vim @ 23827:7e0d8f1cae7d v8.2.2455
patch 8.2.2455: Vim9: key type for literal dict and indexing is inconsistent
Commit: https://github.com/vim/vim/commit/2e5910bfbb05957c10c9c69756dfa342557e9a8b
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Feb 3 17:41:24 2021 +0100
patch 8.2.2455: Vim9: key type for literal dict and indexing is inconsistent
Problem: Vim9: key type that can be used for literal dict and indexing is
inconsistent.
Solution: Allow using number and bool as key for a literal dict. (#7771)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 03 Feb 2021 17:45:06 +0100 |
parents | 525c9e218c69 |
children | 54b583156d53 |
comparison
equal
deleted
inserted
replaced
23826:71d7c2500ee3 | 23827:7e0d8f1cae7d |
---|---|
348 assert_equal('dict<any>', typename(job_info(jobs[0]))) | 348 assert_equal('dict<any>', typename(job_info(jobs[0]))) |
349 job_stop(jobs[0]) | 349 job_stop(jobs[0]) |
350 endif | 350 endif |
351 enddef | 351 enddef |
352 | 352 |
353 def Wrong_dict_key_type(items: list<number>): list<number> | |
354 return filter(items, (_, val) => get({[val]: 1}, 'x')) | |
355 enddef | |
356 | |
357 def Test_filereadable() | 353 def Test_filereadable() |
358 assert_false(filereadable("")) | 354 assert_false(filereadable("")) |
359 assert_false(filereadable(test_null_string())) | 355 assert_false(filereadable(test_null_string())) |
360 | 356 |
361 CheckDefExecFailure(['echo filereadable(123)'], 'E928:') | 357 CheckDefExecFailure(['echo filereadable(123)'], 'E928:') |
408 CheckDefExecFailure(['echo fnamemodify(true, ":p")'], 'E928:') | 404 CheckDefExecFailure(['echo fnamemodify(true, ":p")'], 'E928:') |
409 CheckDefExecFailure(['echo fnamemodify(v:null, ":p")'], 'E928:') | 405 CheckDefExecFailure(['echo fnamemodify(v:null, ":p")'], 'E928:') |
410 CheckDefExecFailure(['echo fnamemodify("file", true)'], 'E928:') | 406 CheckDefExecFailure(['echo fnamemodify("file", true)'], 'E928:') |
411 enddef | 407 enddef |
412 | 408 |
409 def Wrong_dict_key_type(items: list<number>): list<number> | |
410 return filter(items, (_, val) => get({[val]: 1}, 'x')) | |
411 enddef | |
412 | |
413 def Test_filter_wrong_dict_key_type() | 413 def Test_filter_wrong_dict_key_type() |
414 assert_fails('Wrong_dict_key_type([1, 2, 3])', 'E1012:') | 414 assert_fails('Wrong_dict_key_type([1, v:null, 3])', 'E1013:') |
415 enddef | 415 enddef |
416 | 416 |
417 def Test_filter_return_type() | 417 def Test_filter_return_type() |
418 var l = filter([1, 2, 3], () => 1) | 418 var l = filter([1, 2, 3], () => 1) |
419 var res = 0 | 419 var res = 0 |