mirror of
https://github.com/vim/vim.git
synced 2025-09-26 04:04:07 -04:00
patch 8.2.3991: Vim9: error when extending dict<any>
Problem: Vim9: error when extending dict<any> with another type that it was initialized with. Solution: Also set the type for dict<any> if the initializer has a more specific type. (closes #9461)
This commit is contained in:
@@ -757,6 +757,10 @@ def Test_assignment_list()
|
||||
# type becomes list<any>
|
||||
var somelist = rand() > 0 ? [1, 2, 3] : ['a', 'b', 'c']
|
||||
|
||||
# type is list<any> even though initializer is list<number>
|
||||
var anyList: list<any> = [0]
|
||||
assert_equal([0, 'x'], extend(anyList, ['x']))
|
||||
|
||||
var lines =<< trim END
|
||||
var d = {dd: test_null_list()}
|
||||
d.dd[0] = 0
|
||||
@@ -955,6 +959,10 @@ def Test_assignment_dict()
|
||||
# type becomes dict<any>
|
||||
var somedict = rand() > 0 ? {a: 1, b: 2} : {a: 'a', b: 'b'}
|
||||
|
||||
# type is dict<any> even though initializer is dict<number>
|
||||
var anyDict: dict<any> = {a: 0}
|
||||
assert_equal({a: 0, b: 'x'}, extend(anyDict, {b: 'x'}))
|
||||
|
||||
# assignment to script-local dict
|
||||
lines =<< trim END
|
||||
vim9script
|
||||
|
Reference in New Issue
Block a user