summaryrefslogtreecommitdiffstats
path: root/src/eval.c
AgeCommit message (Collapse)Author
2024-03-28patch 9.1.0219: Vim9: No enum supportv9.1.0219Yegappan Lakshmanan
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-11patch 9.1.0168: too many STRLEN() callsv9.1.0168John Marriott
Problem: too many STRLEN() calls Solution: Make use of ml_get_len() calls instead (John Marriott) closes: #14123 Signed-off-by: John Marriott <basilisk@internode.on.net> Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-03-03patch 9.1.0148: Vim9: can't call internal methods with objectsv9.1.0148Yegappan Lakshmanan
Problem: Vim9: can't call internal methods with objects Solution: Add support for empty(), len() and string() function calls for objects (Yegappan Lakshmanan) closes: #14129 Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-02-06patch 9.1.0080: unexpected error for modifying final list using +=v9.1.0080Yegappan Lakshmanan
Problem: unexpected error for modifying final list using += operator (Ernie Rael) Solution: Allow List value modification of a final variable using += operator (Yegappan Lakshmanan) fixes: #13745 fixes: #13959 closes: #13962 Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-01-12patch 9.1.0017: [security]: use-after-free in eval1_emsg()v9.1.0017Yegappan Lakshmanan
Problem: use-after-free in eval1_emsg() when an empty line follows a lambda (by @yu3s) Solution: only set evalarg->eval_using_cmdline = FALSE when the *arg pointer is not null fixes: #13833 closes: #13841 Signed-off-by: Yegappan Lakshmanan <yegappan@yahoo.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-01-04patch 9.1.0006: is*() and to*() function may be unsafev9.1.0006Keith Thompson
Problem: is*() and to*() function may be unsafe Solution: Add SAFE_* macros and start using those instead (Keith Thompson) Use SAFE_() macros for is*() and to*() functions The standard is*() and to*() functions declared in <ctype.h> have undefined behavior for negative arguments other than EOF. If plain char is signed, passing an unchecked value from argv for from user input to one of these functions has undefined behavior. Solution: Add SAFE_*() macros that cast the argument to unsigned char. Most implementations behave sanely for negative arguments, and most character values in practice are non-negative, but it's still best to avoid undefined behavior. The change from #13347 has been omitted, as this has already been separately fixed in commit ac709e2fc0db6d31abb7da96f743c40956b60c3a (v9.0.2054) fixes: #13332 closes: #13347 Signed-off-by: Keith Thompson <Keith.S.Thompson@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
2023-12-21patch 9.0.2184: Vim9: inconsistent :type/:class messagesv9.0.2184Ernie Rael
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-19patch 9.0.2180: POSIX function name in exarg causes issuesv9.0.2180Zoltan Arpadffy
Problem: POSIX function name in exarg struct causes issues on OpenVMS Solution: Rename getline member in exarg struct to ea_getline, remove isinf() workaround for VMS There are compilers that do not treat well POSIX functions - like getline - usage in the structs. Older VMS compilers could digest this... but the newer OpenVMS compilers ( like VSI C x86-64 X7.4-843 (GEM 50XB9) ) cannot deal with these structs. This could be limited to getline() that is defined via getdelim() and might not affect all POSIX functions in general - but avoiding POSIX function names usage in the structs is a "safe side" practice without compromising the functionality or the code readability. The previous OpenVMS X86 port used a workaround limiting the compiler capabilities using __CRTL_VER_OVERRIDE=80400000 In order to make the OpenVMS port future proof, this pull request proposes a possible solution. closes: #13704 Signed-off-by: Zoltan Arpadffy <zoltan.arpadffy@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
2023-12-16patch 9.0.2170: Vim9: no support for const/final class/objects varsv9.0.2170Yegappan Lakshmanan
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-11-11patch 9.0.2096: Vim9: confusing usage of privatev9.0.2096Ernie Rael
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-10-28patch 9.0.2078: several problems with type aliasesv9.0.2078Yegappan Lakshmanan
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-27patch 9.0.2076: Vim9: No support for type aliasesv9.0.2076Yegappan Lakshmanan
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-15patch 9.0.2029: Vim9: no support for partials using call()v9.0.2029Yegappan Lakshmanan
Problem: Vim9: no support for partials using call() Solution: Add support closes: #13341 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-10-15patch 9.0.2027: Vim9: no support for bitwise operators in lambda funcsv9.0.2027Yegappan Lakshmanan
Problem: Vim9: no support for bitwise operators in lambda funcs Solution: move "evaluate" assignment a bit up in order to decide to perform bitwise operations closes: #13342 closes: #13345 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-10-14patch 9.0.2020: Vim9: islocked() needs more workv9.0.2020Ernie Rael
Problem: Vim9: islocked() needs more work Solution: rework islocked() and remove sync_root from get_lval() closes: #13329 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Ernie Rael <errael@raelity.com>
2023-10-14patch 9.0.2019: Vim9: no support for funcrefsv9.0.2019Yegappan Lakshmanan
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-11patch 9.0.2015: Vim9: does not handle islocked() from a method correctlyv9.0.2015Ernie Rael
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-11patch 9.0.2012: Vim9: error message can be more accuratev9.0.2012Ernie Rael
Problem: Vim9: error message can be more accurate Solution: Fix the error messages Fix message for some single use error messages. closes: #13312 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Ernie Rael <errael@raelity.com>
2023-10-07patch 9.0.2001: Vim9: segfault with islocked()v9.0.2001Ernie Rael
Problem: Vim9: segfault with islocked() Solution: Check that the lval pointer is not null for objects and class variables closes: #13295 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Ernie Rael <errael@raelity.com>
2023-10-06patch 9.0.1999: Vim9: some error messages can be improvedv9.0.1999Ernie Rael
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-06patch 9.0.1995: Invalid memory access with empty 'foldexpr'v9.0.1995zeertzjq
Problem: Invalid memory access when 'foldexpr' returns empty string. Solution: Check for NUL. closes: #13293 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: zeertzjq <zeertzjq@outlook.com>
2023-10-05patch 9.0.1986: Vim9: accepting type-annotationsv9.0.1986Yegappan Lakshmanan
Problem: Vim9: accepting type-annotations Solution: Reject type annotations outside of declarations. closes: #13267 closes: #13283 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-10-04patch 9.0.1982: vim9: clean up from v9.0.1955v9.0.1982Ernie Rael
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-09-29patch 9.0.1955: Vim9: lockvar issues with objects/classesv9.0.1955Ernie Rael
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-27patch 9.0.1945: Vim9: missing support for ro-vars in interfacev9.0.1945Yegappan Lakshmanan
Problem: Vim9: missing support for ro-vars in interface Solution: Support only read-only object variables in an interface, add additional checks when parsing class definitions. closes: #13183 cloess: #13184 cloess: #13185. closes: #13188 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-09-24patch 9.0.1935: Vim9: not consistent error messagesv9.0.1935RestorerZ
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-21patch 9.0.1926: Vim9: not enough info in error messagev9.0.1926Ernie Rael
Problem: Vim9: not enough info in error message Solution: Add class name, change member to variable, quote names closes: #13136 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Ernie Rael <errael@raelity.com>
2023-09-20patch 9.0.1920: Vim9: cannot write public var in nested objectv9.0.1920Ernie Rael
Problem: Vim9: cannot write public var in nested object Solution: Write variable in nested read-only object reference. Also test write fails. closes: #13130 closes: #13131 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Ernie Rael <errael@raelity.com>
2023-09-19patch 9.0.1914: Vim9: few issues when accessing object membersv9.0.1914Yegappan Lakshmanan
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-18patch 9.0.1909: Vim9: problem calling class method from other classv9.0.1909Yegappan Lakshmanan
Problem: Vim9: problem calling class method from other class Solution: Fix this problem, fix readonly object access, update error messages. Calling a class method from another method without the class name prefix doesn't work properly. A readonly object variable is modifiable outside the class using a nested object assignment. Remove the unused E1338 error message. Update error messages. closes: #13116 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-09-15patch 9.0.1898: Vim9: restrict access to static varsv9.0.1898Yegappan Lakshmanan
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-10patch 9.0.1890: Vim9: lookup code for class/object repaeatedv9.0.1890Yegappan Lakshmanan
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-05patch 9.0.1869: Coverity warns about unitialized varv9.0.1869Ernie Rael
Problem: Coverity warns about unitialized var Solution: initialize it closes: #13029 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Ernie Rael <errael@raelity.com>
2023-09-04patch 9.0.1867: Vim9: access to interface statics possiblev9.0.1867Ernie Rael
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-04patch 9.0.1865: Vim9: garbage collection may cause crashv9.0.1865Yegappan Lakshmanan
Problem: Vim9: garbage collection may cause crash Solution: validate that class members typeval is not null closes: #13028 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-09-04patch 9.0.1862: Vim9 Garbage Collection issuesv9.0.1862Yegappan Lakshmanan
Problem: Vim9 Garbage Collection issues Solution: Class members are garbage collected early leading to use-after-free problems. Handle the garbage collection of classes properly. closes: #13019 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-08-19patch 9.0.1741: No type checking in interfacesv9.0.1741LemonBoy
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-17patch 9.0.1723: Fix regression in {func} argument of reduce()v9.0.1723zeertzjq
Problem: Fix regression in {func} argument of reduce() Solution: pass function name as string again Before patch 9.0.0548, passing a string as {func} argument of reduce() is treated as a function name, but after patch 9.0.0548 it is treated as an expression instead, which is useless as reduce() doesn't set any v: variables. This PR restores the behavior of {func} before that patch. Also correct an emsg() call, as e_string_list_or_blob_required doesn't contain format specifiers. closes: #12824 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: zeertzjq <zeertzjq@outlook.com>
2023-06-15patch 9.0.1633: duplicate code for converting float to stringv9.0.1633zeertzjq
Problem: Duplicate code for converting float to string. Solution: Use tv_get_string(). (closes #12521)
2023-06-01patch 9.0.1597: cursor ends up below the window after a putv9.0.1597Bram Moolenaar
Problem: Cursor ends up below the window after a put. Solution: Mark w_crow and w_botline invalid when changing the cursor line. (closes #12465)
2023-05-19patch 9.0.1569: cannot use "this.member" in lambda in class methodv9.0.1569h-east
Problem: Cannot use "this.member" in lambda in class method. Solution: Adjust check for reserved keyword. (Hirohito Higashi, closes #12416, closes #12076, closes #12336)
2023-05-05patch 9.0.1508: catch does not work when lines are joined with a newlinev9.0.1508zeertzjq
Problem: Catch does not work when lines are joined with a newline. Solution: Set "nextcmd" appropriately. (closes #12348)
2023-05-02patch 9.0.1505: error when heredoc content looks like heredocv9.0.1505zeertzjq
Problem: Error when heredoc content looks like heredoc. Solution: Handle curly expressions. (closes #12325)
2023-04-13patch 9.0.1452: code using EVAL_CONSTANT is dead, it is never setv9.0.1452zeertzjq
Problem: Code using EVAL_CONSTANT is dead, it is never set. Solution: Remove EVAL_CONSTANT. (closes #12252)
2023-03-11patch 9.0.1401: condition is always truev9.0.1401zeertzjq
Problem: Condition is always true. Solution: Remove the condition. (closes #12139)
2023-03-07patch 9.0.1390: FOR_ALL_ macros are defined in an unexpected filev9.0.1390Yegappan Lakshmanan
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-05patch 9.0.1381: ACCESS_ names have a conflict with on some systemsv9.0.1381=?UTF-8?q?Ola=20S=C3=B6der?=
Problem: ACCESS_ names have a conflict with on some systems. Solution: Rename by prepending VIM_. (Ola Söder, closes #12105)
2023-02-21patch 9.0.1338: :defcompile and :disassemble can't find class methodv9.0.1338Bram Moolenaar
Problem: :defcompile and :disassemble can't find class method. (Ernie Rael) Solution: Make a class name and class.method name work. (closes #11984)
2023-01-30patch 9.0.1266: error for space before ": type" is inconsistentv9.0.1266Bram Moolenaar
Problem: Error for space before ": type" is inconsistent. Solution: Give E1059 in more places. (closes #11868)
2023-01-24patch 9.0.1239: cannot have a line break before an object member accessv9.0.1239Bram Moolenaar
Problem: Cannot have a line break before an object member access. Solution: Check for "." in next line. (closes #11864)