0
0
mirror of https://github.com/vim/vim.git synced 2025-07-04 23:07:33 -04:00

503 Commits

Author SHA1 Message Date
Yegappan Lakshmanan
f3eac695bf
patch 9.0.2038: Vim9: object method funcref not cleaned up after use
Problem:  Vim9: object method funcref not cleaned up after use
Solution: Clean up type stack after using object method funcref,
          remove now longer used ISN_DEFEROBJ instrunction

closes: #13360

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-10-17 11:00:45 +02:00
Yegappan Lakshmanan
29bb67f1be
patch 9.0.2019: Vim9: no support for funcrefs
Problem:  Vim9: no support for funcrefs
Solution: Add support for object/class funcref members

closes: #11981 #12417 #12960 #12324 #13333

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-10-14 11:18:50 +02:00
Ernie Rael
4c8da025ef
patch 9.0.2015: Vim9: does not handle islocked() from a method correctly
Problem:  Vim9: does not handle islocked() from a method correctly
Solution: Handle islocked() builtin from a method.

- Setup `lval_root` from `f_islocked()`.
- Add function `fill_exec_lval_root()` to get info about executing method.
- `sync_root` added in get_lval to handle method member access.
- Conservative approach to reference counting.

closes: #13309

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Ernie Rael <errael@raelity.com>
2023-10-11 21:38:24 +02:00
Yegappan Lakshmanan
1087b8c29a
patch 9.0.2000: Vim9: use-after-free in deep call stack
Problem:  Vim9: use-after-free in deep call stack
Solution: Get the objct pointer from execution stack

closes: #13296

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-10-07 22:03:18 +02:00
Ernie Rael
e6c9aa5e6a
patch 9.0.1999: Vim9: some error messages can be improved
Problem:  Vim9: some error messages can be improved
Solution: Mention the defining class for variable access error message

closes: #13272

Signed-off-by: Christian Brabandt <cb@256bit.org>
Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Co-authored-by: Ernie Rael <errael@raelity.com>
2023-10-06 19:55:52 +02:00
Ernie Rael
64885645e7
patch 9.0.1982: vim9: clean up from v9.0.1955
Problem:  vim9: clean up from v9.0.1955
Solution: Fix a few remaining issues, improve error message

- Use `cl_exec`, the executing class, to check permissions in `get_lval()`.
- Handle lockvar of script variable from class.
- Add 'in class "Xxx"' to e_cannot_access_private_variable_str.

closes: #13222

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Ernie Rael <errael@raelity.com>
2023-10-04 20:16:22 +02:00
Ernie Rael
ee865f37ac
patch 9.0.1955: Vim9: lockvar issues with objects/classes
Problem:  Vim9: lockvar issues with objects/classes
Solution: fix `get_lhs()` object/class access and avoid `SEGV`,
          make error messages more accurate.

- `get_lval()` detects/returns object/class access
- `compile_lock_unlock()` generate code for bare static and obj_arg access
- `do_lock_var()` check lval for `ll_object`/`ll_class` and fail if so.

Details:
- Add `ll_object`/`ll_class`/`ll_oi` to `lval_T`.
- Add `lockunlock_T` to `isn_T` for `is_arg` to specify handling of `lval_root` in `get_lval()`.
- In `get_lval()`, fill in `ll_object`/`ll_class`/`ll_oi` as needed; when no `[idx] or .key`, check lval_root on the way out.
- In `do_lock_var()` check for `ll_object`/`ll_class`; also bullet proof ll_dict case
  and give `Dictionay required` if problem. (not needed to avoid lockvar crash anymore)
- In `compile_lock_unlock()` compile for the class variable and func arg cases.

closes: #13174

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Ernie Rael <errael@raelity.com>
2023-09-29 19:53:55 +02:00
Yegappan Lakshmanan
5a05d374d3
patch 9.0.1952: Vim9: unused static field
Problem:  Vim9: unused static field
Solution: remove it and simplify code

closes: #13220

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-09-29 19:44:25 +02:00
Yegappan Lakshmanan
c1946267f2
patch 9.0.1942: Vim9: execution stack invalidated with null object
Problem:  Vim9: execution stack invalidated with null object
Solution: Check for a null object before adjusting the execution stack

closes: #13186

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-09-25 21:00:46 +02:00
RestorerZ
7fe8f43f49
patch 9.0.1935: Vim9: not consistent error messages
Problem:  Vim9: not consistent error messages
Solution: Make error messages more consistent. Use "variable" for
          (object/class) member

closes: #13155

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: RestorerZ <restorer@mail2k.ru>
2023-09-24 23:21:24 +02:00
Yegappan Lakshmanan
7398f367d5
patch 9.0.1932: Vim9: error when using null object constructor
Problem:  Vim9: error when using null object constructor
Solution: Check for a null object only when calling an object method

closes: #13154
closes: #13163

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-09-24 23:09:10 +02:00
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