1
0
forked from aniani/vim

492 Commits

Author SHA1 Message Date
h-east
b895b0fabc
patch 9.0.1928: Vim9: constructor type checking bug
Problem:  Vim9: constructor type checking bug
Solution: Fix class constructor regression

closes: #13102
closes: #13113

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: h-east <h.east.727@gmail.com>
2023-09-24 15:46:31 +02:00
Yegappan Lakshmanan
1db1514365
patch 9.0.1914: Vim9: few issues when accessing object members
Problem:  Vim9: few issues when accessing object members
Solution: When calling an object method, check for null object.
          Accessing a Dict object member doesn't work.

closes: #13119
closes: #13123
closes: #13124

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-09-19 20:36:02 +02:00
Yegappan Lakshmanan
c30a90d9b2
patch 9.0.1898: Vim9: restrict access to static vars
Problem:  Vim9: restrict access to static vars and methods
Solution: Class members are accesible only from the class where they are
          defined.

Based on the #13004 discussion, the following changes are made:

    1) Static variables and methods are accessible only using the class
       name and inside the class where they are defined.
    2) Static variables and methods can be used without the class name in
       the class where they are defined.
    3) Static variables of a super class are not copied to the sub class.
    4) A sub class can declare a class variable with the same name as the
       super class.
    5) When a method or member is found during compilation, use more
       specific error messages.

This aligns the Vim9 class variable/method implementation with the Dart
implementation.

Also while at it, ignore duplicate class and object methods.

The access level of an object method can however be changed in a
subclass.

For the tests, use the new CheckSourceFailure() function instead of the
CheckScriptFailure() function in the tests.

closes: #13086

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-09-15 20:14:55 +02:00
Yegappan Lakshmanan
f36bbcd402
patch 9.0.1890: Vim9: lookup code for class/object repaeated
Problem:  Vim9: lookup code for class/object repaeated
Solution: Refactor and make use of lookup functions

closes: #13067

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-09-10 18:19:06 +02:00
Ernie Rael
00df69e62b
patch 9.0.1870: Vim9: disassamble does not show static
Problem:  Vim9: disassamble does not show static
Solution: Show static flag

Fix disassemble for instructions with optional static:
ISN_GET_OBJ_MEMBER and ISN_GET_ITF_MEMBER

closes: #13030

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Ernie Rael <errael@raelity.com>
2023-09-05 07:39:14 +02:00
Ernie Rael
18143d3111
patch 9.0.1867: Vim9: access to interface statics possible
Problem:  Vim9: access to interface statics possible
Solution: Prevent direct access to interface statics

closes: #13007

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Ernie Rael <errael@raelity.com>
2023-09-04 22:30:41 +02:00
LemonBoy
32f3461465
patch 9.0.1850: Vim9: wrong line number where options set
Problem:  Vim9: wrong line number where options set
Solution: Set source line number earlier

closes: #13006
closes: #13013

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: LemonBoy <thatlemon@gmail.com>
2023-09-02 21:52:05 +02:00
Yegappan Lakshmanan
3775f777a6
patch 9.0.1838: Vim9: Cannot modify class member vars from def function
Problem:  Vim9: Cannot modify class member vars from def function
Solution: Add support for modifying class member variables from a def
          function

closes: #12995

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-09-01 22:05:45 +02:00
Gianmaria Bajo
d7085a0635
patch 9.0.1830: Vim9: crash when accessing a null object
Problem:  Vim9: crash when accessing a null object
Solution: Check accessing a NULL object in def function

An object is NULL when the variable is declared, but the constructor
isn't called. Accessing/setting a member on the object crashed Vim.

Note: this happens inside def functions, at script level things work
differently. Accessing a NULL object member results in E1360
(correctly), while setting a value on it results in E1012 (type
mismatch) so there's still something to fix.

closes: #12973

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Gianmaria Bajo <mg1979.git@gmail.com>
2023-08-31 18:15:26 +02:00
LemonBoy
f244b2fbf2
patch 9.0.1754: still Ci breakage (after 9.0.1741)
Problem: still ci breakage (after 9.0.1741)
Solution: fix remaining issue

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: LemonBoy <thatlemon@gmail.com>
2023-08-19 16:02:04 +02:00
LemonBoy
c5d2744c04
patch 9.0.1741: No type checking in interfaces
Problem: No type checking in interfaces
Solution: Implement member type check in vim9 interfaces

Most of the code is a small refactoring to allow the use of a where_T
for signaling the type mismatch, the type checking itself is pretty
simple.

Improve where_T error reports

Let the caller explicitly define the kind of location it's referring to
and free the WT_ARGUMENT enum from its catch-all role.

Implement type checking for interface methods

Follows closely the logic used for type-checking the members.

closes: #12844

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: LemonBoy <thatlemon@gmail.com>
2023-08-19 13:04:53 +02:00
Bram Moolenaar
4e2406c7a9 patch 9.0.1662: crash when using a class member twice
Problem:    Crash when using a class member twice. (Christian J. Robinson)
Solution:   Make a copy of the value.
2023-06-24 19:22:21 +01:00
Bram Moolenaar
d4a9b7f614 patch 9.0.1573: error for function name has wrong line number
Problem:    Error for function name has wrong line number.
Solution:   Set the line number before giving the error.
2023-05-23 14:48:42 +01:00
Bram Moolenaar
3ef2e41128 patch 9.0.1501: crash with nested :try and :throw in catch block
Problem:    Crash with nested :try and :throw in catch block.
Solution:   Jump to :endtry before returning from function. (closes #12245)
2023-04-30 18:50:48 +01:00
zeertzjq
a1f2b5ddc6 patch 9.0.1468: recursively calling :defer function if it does :qa
Problem:    Recursively calling :defer function if it does :qa in a compiled
            function.
Solution:   Clear the defer entry before calling the function. (closes #12271)
2023-04-18 21:04:53 +01:00
Bram Moolenaar
2ed57ac367 patch 9.0.1436: cannot compare a typed variable with v:none
Problem:    Cannot compare a typed variable with v:none.
Solution:   Allow for "x is v:none" and "x isnot v:none". (issue #12194)
2023-04-01 22:05:38 +01:00
Yegappan Lakshmanan
14113fdf9c patch 9.0.1390: FOR_ALL_ macros are defined in an unexpected file
Problem:    FOR_ALL_ macros are defined in an unexpected file.
Solution:   Move FOR_ALL_ macros to macros.h.  Add FOR_ALL_HASHTAB_ITEMS.
            (Yegappan Lakshmanan, closes #12109)
2023-03-07 17:13:51 +00:00
Bram Moolenaar
c3f971f289 patch 9.0.1370: crash when using a NULL object
Problem:    Crash when using a NULL object. (Ernie Rael)
Solution:   Check for NULL and give an error message. (closes #12083)
2023-03-02 17:38:33 +00:00
Bram Moolenaar
30a8447715 patch 9.0.1358: compilation error with some compilers
Problem:    Compilation error with some compilers.
Solution:   Avoid using "class" as member name.
2023-02-27 08:07:14 +00:00
Bram Moolenaar
c4e1b86cb0 patch 9.0.1357: using null_object results in an internal error
Problem:    Using null_object results in an internal error. (Ernie Rael)
Solution:   Add instructions for pushing an object and class. (closes #12044)
2023-02-26 18:58:23 +00:00
Bram Moolenaar
2c1c803c7e patch 9.0.1322: crash when indexing "any" which is an object
Problem:    Crash when indexing "any" which is an object.
Solution:   Check the index is a number.  Do not check the member type of an
            object.  (closes #12019)
2023-02-18 18:38:37 +00:00
Bram Moolenaar
0917e86763 patch 9.0.1320: checking the type of a null object causes a crash
Problem:    Checking the type of a null object causes a crash.
Solution:   Don't try to get the class of a null object. (closes #12005)
            Handle error from calling a user function better.
2023-02-18 14:42:44 +00:00
Bram Moolenaar
094cf9f4d5 patch 9.0.1296: calling an object method with arguments does not work
Problem:    Calling an object method with arguments does not work. (Ernie
            Rael)
Solution:   Take the argument count into account when looking up the object.
            (closes #11911)
2023-02-10 15:52:25 +00:00
Bram Moolenaar
313e4724c3 patch 9.0.1292: :defer may call the wrong method for an object
Problem:    :defer may call the wrong method for an object. (Ernie Rael)
Solution:   When en object is from a class that extends or implements, figure
            out the method to call at runtime. (closes #11910)
2023-02-08 20:55:27 +00:00
Bram Moolenaar
d0200c8631 patch 9.0.1254: calling a method on an interface does not work
Problem:    Calling a method on an interface does not work.
Solution:   At runtime figure out what method to call. (closes #11901)
2023-01-28 15:19:40 +00:00
Bram Moolenaar
8dbab1d8ce patch 9.0.1250: cannot use an object method with :defer
Problem:    Cannot use an object method with :defer. (Ernie Rael)
Solution:   Find the object method and generate code to call it.
            (closes #11886)
2023-01-27 20:14:02 +00:00
Yegappan Lakshmanan
142ed77898 patch 9.0.1246: code is indented more than necessary
Problem:    Code is indented more than necessary.
Solution:   Use an early return where it makes sense. (Yegappan Lakshmanan,
            closes #11887)
2023-01-26 12:00:00 +00:00
Bram Moolenaar
47bba53bdb patch 9.0.1224: cannot call a :def function with a number for float argument
Problem:    Cannot call a :def function with a number for a float argument.
Solution:   Accept a number as well, convert it to a float.
2023-01-20 18:49:46 +00:00
Bram Moolenaar
f7d1c6e188 patch 9.0.1211: storing value in interface member does not always work
Problem:    Storing value in interface member does not always work.
Solution:   Convert the index on the interface to the index on the object.
2023-01-16 20:47:57 +00:00
Bram Moolenaar
29ac5df37b patch 9.0.1209: getting interface member does not always work
Problem:    Getting interface member does not always work.
Solution:   Convert the index on the interface to the index on the object.
            (closes #11825)
2023-01-16 19:43:47 +00:00
Bram Moolenaar
554d031302 patch 9.0.1150: :interface is not implemented yet
Problem:    :interface is not implemented yet.
Solution:   Implement the basics of :interface.
2023-01-05 19:59:18 +00:00
Bram Moolenaar
574950dfb1 patch 9.0.1140: cannot call an object method in a compiled function
Problem:    Cannot call an object method in a compiled function.
Solution:   Compile the instructins to invoke an object method.
2023-01-03 19:08:50 +00:00
Bram Moolenaar
03ff0c6681 patch 9.0.1135: missing function argument
Problem:    Missing function argument.
Solution:   Add ignore case flag.
2023-01-02 20:38:01 +00:00
Bram Moolenaar
bcf31ec36b patch 9.0.1134: comparing objects uses identity instead of equality
Problem:    Comparing objects uses identity instead of equality.
Solution:   Compare the object values.
2023-01-02 20:32:24 +00:00
Bram Moolenaar
a9fa8c58fb patch 9.0.1133: error message names do not match the items
Problem:    Error message names do not match the items.
Solution:   Add "_str" when the text contains "%s".
2023-01-02 18:10:04 +00:00
Bram Moolenaar
0d89d8ae89 patch 9.0.1119: type of arguments not checked when calling a partial
Problem:    Type of arguments not checked when calling a partial.
Solution:   Give an error for a wrong argument type. (closes #11753)
2022-12-31 14:01:24 +00:00
Bram Moolenaar
c6951a76a5 patch 9.0.1108: type error when using "any" type and adding to float
Problem:    Type error when using "any" type and adding a number to a float.
Solution:   Accept both a number and a float. (closes #11753)
2022-12-29 20:56:24 +00:00
Bram Moolenaar
590162cae0 patch 9.0.1093: using freed memory of object member
Problem:    Using freed memory of object member. (Yegappan Lakshmanan)
Solution:   Make a copy of the object member when getting it.
2022-12-24 21:24:06 +00:00
Bram Moolenaar
d505d17885 patch 9.0.1074: class members are not supported yet
Problem:    Class members are not supported yet.
Solution:   Add initial support for class members.
2022-12-18 21:42:55 +00:00
Bram Moolenaar
65b0d16768 patch 9.0.1053: default constructor arguments are not optional
Problem:    Default constructor arguments are not optional.
Solution:   Use "= v:none" to make constructor arguments optional.
2022-12-13 18:43:22 +00:00
Bram Moolenaar
7ce7daf6cd patch 9.0.1045: in a class object members cannot be initialized
Problem:    In a class object members cannot be initialized.
Solution:   Support initializing object members. Make "dissassemble" work on
            an object method.
2022-12-10 18:42:12 +00:00
Bram Moolenaar
ffdaca9e6f patch 9.0.1041: cannot define a method in a class
Problem:    Cannot define a method in a class.
Solution:   Implement defining an object method.  Make calling an object
            method work.
2022-12-09 21:41:48 +00:00
Bram Moolenaar
d28d7b94f5 patch 9.0.1035: object members are not being marked as used
Problem:    Object members are not being marked as used, garbage collection
            may free them.
Solution:   Mark object members as used.  Fix reference counting.
2022-12-08 20:42:00 +00:00
Bram Moolenaar
00b28d6c23 patch 9.0.1031: Vim9 class is not implemented yet
Problem:    Vim9 class is not implemented yet.
Solution:   Add very basic class support.
2022-12-08 15:32:33 +00:00
Bram Moolenaar
ef2c325f5e patch 9.0.0949: crash when unletting a variable while listing variables
Problem:    Crash when unletting a variable while listing variables.
Solution:   Disallow changing a hashtable while going over the entries.
            (closes #11435)
2022-11-25 16:31:51 +00:00
dundargoc
c57b5bcd22 patch 9.0.0828: various typos
Problem:    Various typos.
Solution:   Correct typos. (closes #11432)
2022-11-02 13:30:51 +00:00
Bram Moolenaar
bdc09a18fc patch 9.0.0683: cannot specify a time for :echowindow
Problem:    Cannot specify a time for :echowindow.
Solution:   A count can be used to specify the display time. Add
            popup_findecho().
2022-10-07 14:31:45 +01:00
Bram Moolenaar
87b4e5c5db patch 9.0.0632: calling a function from an "expr" option has overhead
Problem:    Calling a function from an "expr" option has too much overhead.
Solution:   Add call_simple_func() and use it for 'foldexpr'
2022-10-01 15:32:46 +01:00
Bram Moolenaar
1936c76536 patch 9.0.0617: calling function for reduce() has too much overhead
Problem:    Calling function for reduce() has too much overhead.
Solution:   Only call clear_tv() when needed.
2022-09-28 15:19:10 +01:00
Bram Moolenaar
5800c79838 patch 9.0.0549: duplicated code in calling a :def function
Problem:    Duplicated code in calling a :def function.
Solution:   Simplify the code.
2022-09-22 17:34:01 +01:00