patch 8.2.4390: Vim9: list from declaration with inferred type not set

Problem:    Vim9: list from declaration with inferred type does not set the
            type on the value.
Solution:   When inferring the type in a variable declaration also set the
            type of the list or dictionary. (closes #9705)  Do not set the
            type when the member is "any".
diff --git a/src/testdir/test_vim9_assign.vim b/src/testdir/test_vim9_assign.vim
index 8a00ceb..9c988c9 100644
--- a/src/testdir/test_vim9_assign.vim
+++ b/src/testdir/test_vim9_assign.vim
@@ -1885,6 +1885,19 @@
   v9.CheckDefFailure(['const foo: number'], 'E1021:')
 enddef
 
+def Test_var_declaration_inferred()
+  # check that type is set on the list so that extend() fails
+  var lines =<< trim END
+      vim9script
+      def GetList(): list<number>
+        var l = [1, 2, 3]
+        return l
+      enddef
+      echo GetList()->extend(['x'])
+  END
+  v9.CheckScriptFailure(lines, 'E1013:', 6)
+enddef
+
 def Test_script_local_in_legacy()
   # OK to define script-local later but before compiling
   var lines =<< trim END
diff --git a/src/testdir/test_vim9_builtin.vim b/src/testdir/test_vim9_builtin.vim
index 23b9c49..09cfd70 100644
--- a/src/testdir/test_vim9_builtin.vim
+++ b/src/testdir/test_vim9_builtin.vim
@@ -1129,6 +1129,7 @@
       def Test()
         var d: dict<any> = {}
         d->extend({A: 10, Func: function('F', [])})
+        d.Func()
       enddef
 
       Test()
diff --git a/src/testdir/test_vim9_disassemble.vim b/src/testdir/test_vim9_disassemble.vim
index ec71836..91464a7 100644
--- a/src/testdir/test_vim9_disassemble.vim
+++ b/src/testdir/test_vim9_disassemble.vim
@@ -427,6 +427,7 @@
         '\d PUSHS "dd"\_s*' ..
         '\d NEWDICT size 0\_s*' ..
         '\d NEWDICT size 1\_s*' ..
+        '\d SETTYPE dict<dict<unknown>>\_s*' ..
         '\d STORE $0\_s*' ..
         'd.dd\[0\] = 0\_s*' ..
         '\d PUSHNR 0\_s*' ..
@@ -457,7 +458,6 @@
         '\d STORE $1\_s*' ..
         'var l: list<any>\_s*' ..
         '\d NEWLIST size 0\_s*' ..
-        '\d SETTYPE list<any>\_s*' ..
         '\d STORE $2\_s*' ..
         '\[x, y; l\] = g:stringlist\_s*' ..
         '\d LOADG g:stringlist\_s*' ..
@@ -470,7 +470,6 @@
         '\d\+ CHECKTYPE string stack\[-1\] arg 2\_s*' ..
         '\d\+ STORE $1\_s*' ..
         '\d\+ SLICE 2\_s*' ..
-        '\d\+ SETTYPE list<any>\_s*' ..
         '\d\+ STORE $2\_s*' ..
         '\d\+ RETURN void',
         res)
@@ -615,13 +614,14 @@
   lockvar d.a
 enddef
 
-def Test_disassemble_locl_local()
+def Test_disassemble_lock_local()
   var res = execute('disass s:LockLocal')
   assert_match('<SNR>\d*_LockLocal\_s*' ..
         'var d = {a: 1}\_s*' ..
         '\d PUSHS "a"\_s*' ..
         '\d PUSHNR 1\_s*' ..
         '\d NEWDICT size 1\_s*' ..
+        '\d SETTYPE dict<number>\_s*' ..
         '\d STORE $0\_s*' ..
         'lockvar d.a\_s*' ..
         '\d LOAD $0\_s*' ..
@@ -1626,6 +1626,7 @@
         '\d PUSHNR 2\_s*' ..
         '\d PUSHNR 3\_s*' ..
         '\d NEWLIST size 3\_s*' ..
+        '\d SETTYPE list<number>\_s*' ..
         '\d STORE $0\_s*' ..
         'var res = l\[1]\_s*' ..
         '\d LOAD $0\_s*' ..
@@ -1650,13 +1651,15 @@
         '\d PUSHNR 2\_s*' ..
         '\d PUSHNR 3\_s*' ..
         '\d NEWLIST size 3\_s*' ..
+        '\d SETTYPE list<number>\_s*' ..
         '\d STORE $0\_s*' ..
         'var res = l\[1 : 8]\_s*' ..
         '\d LOAD $0\_s*' ..
         '\d PUSHNR 1\_s*' ..
         '\d PUSHNR 8\_s*' ..
-        '\d LISTSLICE\_s*' ..
-        '\d STORE $1\_s*',
+        '\d\+ LISTSLICE\_s*' ..
+        '\d\+ SETTYPE list<number>\_s*' ..
+        '\d\+ STORE $1\_s*',
         instr)
   assert_equal([2, 3], ListSlice())
 enddef
@@ -1675,6 +1678,7 @@
         '\d PUSHS "item"\_s*' ..
         '\d PUSHNR 1\_s*' ..
         '\d NEWDICT size 1\_s*' ..
+        '\d SETTYPE dict<number>\_s*' ..
         '\d STORE $0\_s*' ..
         'var res = d.item\_s*' ..
         '\d\+ LOAD $0\_s*' ..
@@ -2541,6 +2545,7 @@
           '\d PUSHS "func"\_s*' ..
           '\d PUSHFUNC "<80><fd>R\d\+_Legacy"\_s*' ..
           '\d NEWDICT size 1\_s*' ..
+          '\d SETTYPE dict<func(...): any>\_s*' ..
           '\d STORE $0\_s*' ..
 
           'var v = d.func()\_s*' ..