summaryrefslogtreecommitdiffstats
path: root/runtime
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-08-09 17:22:04 +0200
committerBram Moolenaar <Bram@vim.org>2020-08-09 17:22:04 +0200
commit127542bcebeb6480493b09d75a3be1d98a5f7797 (patch)
tree6fab1472b83f66f4a453e11bbc5ee9611a00fb40 /runtime
parenta1b9b0cc011ef15869ac25cb93e1b4baa0cb7f38 (diff)
patch 8.2.1407: Vim9: type of list and dict only depends on first itemv8.2.1407
Problem: Vim9: type of list and dict only depends on first item. Solution: Use all items to decide about the type.
Diffstat (limited to 'runtime')
-rw-r--r--runtime/doc/vim9.txt8
1 files changed, 8 insertions, 0 deletions
diff --git a/runtime/doc/vim9.txt b/runtime/doc/vim9.txt
index 7f7b15bb23..8ff70595f4 100644
--- a/runtime/doc/vim9.txt
+++ b/runtime/doc/vim9.txt
@@ -619,6 +619,8 @@ called in the same way the declaration is the same.
Custom types can be defined with `:type`: >
:type MyList list<string>
+Custom types must start with a capital letter, to avoid name clashes with
+builtin types added later, similarly to user functions.
{not implemented yet}
And classes and interfaces can be used as types: >
@@ -645,6 +647,12 @@ declaring a variable and giving it a value: >
let var = 0 " infers number type
let var = 'hello' " infers string type
+The type of a list and dictionary comes from the common type of the values.
+If the values all have the same type, that type is used for the list or
+dictionary. If there is a mix of types, the "any" type is used. >
+ [1, 2, 3] list<number>
+ ['a', 'b', 'c'] list<string>
+ [1, 'x', 3] list<any>
==============================================================================