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

519 Commits

Author SHA1 Message Date
Yegappan Lakshmanan
bce51d9005
patch 9.1.0335: String interpolation fails for List type
Problem:  String interpolation fails for List type
Solution: use implicit string(list) for string interpolation and :put =
          (Yegappan Lakshmanan)

related: #14529
closes: #14556

Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-04-15 19:19:52 +02:00
Yegappan Lakshmanan
f01493c550
patch 9.1.0329: String interpolation fails for Dict type
Problem:  String interpolation fails for Dict type
Solution: Support Dict data type properly, also support :put =Dict
          (without having to convert it to string() first)
          (Yegappan Lakshmanan)

fixes: #14529
closes: #14541

Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-04-14 23:21:02 +02:00
Christian Brabandt
915f3bf4c1
patch 9.1.0270: a few minor issues to fix
The following is a collection of some small fixes:

- Problem:  Vim9: funcref pointer pt leaks, when function is not found
  Solution: Free funcref pointer in case of error (fixes: #14254)

- Problem:  memory leak of crypt state pointer allocation fails
  Solution: free crypt state pointer properly (fixes: #14253)

- Problem:  Vim9: Leaking memory when compiling dict fails
  Solution: Free the memory in case of error (fixes: #14252)

- Problem:  Coverity complains about derefencing obj_members pointer
            (after v9.1.0261)
  Solution: Verify that obj_members ptr is non-null before accessing it

  References: https://scan5.scan.coverity.com/#/project-view/41242/10101?selectedIssue=1596133

closes: #14412

Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-04-05 20:12:19 +02:00
Yegappan Lakshmanan
3164cf8f12
patch 9.1.0219: Vim9: No enum support
Problem:  No enum support
Solution: Implement enums for Vim9 script
          (Yegappan Lakshmanan)

closes: #14224

Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-03-28 10:38:28 +01:00
Christian Brabandt
86eddced7e
patch 9.1.0209: leaking memory in exe_newdict() on error
Problem:  leaking memory in exe_newdict() on error
          (LuMingYinDetect)
Solution: free allocated dict if GA_GROW_FALIS()

fixes: #14255
closes: #14281

Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-03-26 18:42:52 +01:00
Ernie Rael
e75fde6b04
patch 9.0.2184: Vim9: inconsistent :type/:class messages
Problem:  Vim9: inconsistent :type/:class messages
Solution: Update the Messages (Ernie Rael)

closes: #13706

Signed-off-by: Ernie Rael <errael@raelity.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2023-12-21 17:18:54 +01:00
Yegappan Lakshmanan
e5437c5427
patch 9.0.2170: Vim9: no support for const/final class/objects vars
Problem:  Vim9: no support for const/final class/objects vars
Solution: Support final and const object and class variables

closes: #13655

Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2023-12-16 14:11:19 +01:00
Ernie Rael
b077b58809
patch 9.0.2164: Vim9: can use type a func arg/return value
Problem:  Vim9: can use type a func arg/return value
Solution: Check if using type as function argument or return value

closes: #13675

Signed-off-by: Ernie Rael <errael@raelity.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2023-12-14 20:14:13 +01:00
Ernie Rael
9ed53752df
patch 9.0.2156: Vim9: can use typealias in assignment
Problem:  Vim9: can use typealias in an assignment
Solution: Generate errors when class/typealias involved in the rhs of an
          assignment

closes: #13637

Signed-off-by: Ernie Rael <errael@raelity.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Generate errors when class/typealias involved in assignment.
2023-12-11 17:40:46 +01:00
Christian Brabandt
5dd41d4b63
patch 9.0.2149: [security]: use-after-free in exec_instructions()
Problem:  [security]: use-after-free in exec_instructions()
Solution: get tv pointer again

[security]: use-after-free in exec_instructions()

exec_instructions may access freed memory, if the GA_GROWS_FAILS()
re-allocates memory. When this happens, the typval tv may still point to
now already freed memory. So let's get that pointer again and compare it
with tv. If those two pointers differ, tv is now invalid and we have to
refresh the tv pointer.

closes: #13621

Signed-off-by: Christian Brabandt <cb@256bit.org>
2023-12-04 22:54:43 +01:00
mityu
a555069b7d
patch 9.0.2129: [security]: use-after-free in call_dfunc()
Problem:  [security]: use-after-free in call_dfunc()
Solution: Refresh dfunc pointer

closes: #13571

This Commit fixes a SEGV caused by a use-after-free bug in call_dfunc().
When calling check_ufunc_arg_types() from the call_dfunc() it may cause
def functions to be re-compiled and if there are too many def functions,
the def_functions array will be re-allocated.  Which means, that the
dfunc pointer in call_dfunc() now starts pointing to freed memory.

So we need to reset the dfunc pointer after calling
check_ufunc_arg_types().

Let's also add a test, to ensure we do not regress.

Signed-off-by: mityu <mityu.mail@gmail.com>
Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2023-11-25 15:41:20 +01:00
Ernie Rael
03042a2753
patch 9.0.2096: Vim9: confusing usage of private
Problem:  Vim9: confusing usage of private
Solution: clarify and use protected keyword instead

[vim9class] document `_` as protected instead of private

fixes #13504
closes: #13520

Signed-off-by: Ernie Rael <errael@raelity.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2023-11-11 08:53:32 +01:00
Yegappan Lakshmanan
feaccd2395
patch 9.0.2078: several problems with type aliases
Problem:  several problems with type aliases
Solution: Check for more error conditions, add tests,
          fix issues

Check for more error conditions and add additional tests

fixes  #13434
fixes  #13437
fixes  #13438
closes #13441

Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2023-10-28 15:53:55 +02:00
Yegappan Lakshmanan
ec3cebbd2b
patch 9.0.2076: Vim9: No support for type aliases
Problem:  Vim9: No support for type aliases
Solution: Implement :type command

A type definition is giving a name to a type specification.  This also known
type alias.

	:type ListOfStrings = list<string>

The type alias can be used wherever a built-in type can be used.  The type
alias name must start with an upper case character.

closes: #13407

Signed-off-by: Christian Brabandt <cb@256bit.org>
Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-10-27 19:35:26 +02:00
Yegappan Lakshmanan
c59c1e0d88
patch 9.0.2050: Vim9: crash with deferred function call and exception
Problem:  Vim9: crash with deferred function call and exception
Solution: Save and restore exception state

Crash when a deferred function is called after an exception and another
exception is thrown

closes: #13376
closes: #13377

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-10-19 10:52:34 +02:00
Yegappan Lakshmanan
0672595fd5
patch 9.0.2044: Vim9: exceptions confuse defered functions
Problem:  Vim9: exceptions confuse defered functions
Solution: save and restore exception state when calling defered
          functions

closes: #13364
closes: #13372

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