summaryrefslogtreecommitdiffstats
path: root/src/testdir/test_vim9_class.vim
AgeCommit message (Collapse)Author
2023-09-28patch 9.0.1951: Vim9: hard to debug vim9_class errors from CIv9.0.1951Yegappan Lakshmanan
Problem: Vim9: hard to debug vim9_class errors from CI Solution: Include the line number in assert_xxx() calls. Include the entire error message in the tests. Fix the indentation in the test file. Add tags for new error codes. closes: #13206 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-09-28patch 9.0.1949: Vim9: allows reserved keywords as membersv9.0.1949Yegappan Lakshmanan
Problem: Vim9: allows reserved keywords as members Solution: Disallow reserved keywords, disallow duplicate object and class variables closes: #13209 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-09-28patch 9.0.1948: Vim9: object variable "this." should only be used in constructorv9.0.1948h-east
Problem: Vim9: object variable "this." should only be used in constructor Solution: Disallow to this in normal object methods (other than constructors) closes: #13152 closes: #13212 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: h-east <h.east.727@gmail.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-24patch 9.0.1932: Vim9: error when using null object constructorv9.0.1932Yegappan Lakshmanan
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-24patch 9.0.1928: Vim9: constructor type checking bugv9.0.1928h-east
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-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-19patch 9.0.1911: Vim9: segfault with null object and instanceof()v9.0.1911Ernie Rael
Problem: Vim9: segfault with null object and instanceof() Solution: return early closes: #13121 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Ernie Rael <errael@raelity.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-17patch 9.0.1906: Vim9: Interfaces should not support class methods and variablesv9.0.1906Yegappan Lakshmanan
Problem: Vim9: Interfaces should not support class methods and variables Solution: Make sure interface follow the interface specification Vim9 interface changes to follow the new interface specification: 1) An interface can have only read-only and read-write instance variables. 2) An interface can have only public instance methods. 3) An interface cannot have class variables and class methods. 4) An interface cannot have private instance variables and private instance methods. 5) A interface can extend another interface using "extends". The sub-interface gets all the variables and methods in the super interface. That means: - Interfaces should not support class methods and variables. - Adjust error numbers and add additional tests. - Interface methods can be defined in one of the super classes. - Interface variables can be defined in one of the super classes. and instance variables can be repeated in sub interfaces. - Check the class variable types with the type in interface. closes: #13100 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-09patch 9.0.1888: Vim9: Problem trying to invoke class methodv9.0.1888Yegappan Lakshmanan
Problem: Vim9: Problem trying to invoke class method Solution: Lookup the class method insider other classes closes: #13055 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-09-09patch 9.0.1887: Vim9: class members are accessible via objectv9.0.1887Yegappan Lakshmanan
Problem: Vim9: class members are accessible via object Solution: Disable class member variable access using an object Class methods can be accessed only using the class name and cannot be accessed using an object. To be consistent with this, do the same for class member variables also. They can be accessed only using the class name and not using an object. closes: #13057 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-09-09patch 9.0.1886: Various Typosv9.0.1886Christian Brabandt
Problem: Various Typos Solution: Fix Typos This is a collection of typo related commits. closes: #12753 closes: #13016 Co-authored-by: Adri Verhoef <a3@a3.xs4all.nl> Co-authored-by: zeertzjq <zeertzjq@outlook.com> Co-authored-by: Viktor Szépe <viktor@szepe.net> Co-authored-by: nuid64 <lvkuzvesov@proton.me> Co-authored-by: Meng Xiangzhuo <aumo@foxmail.com> Co-authored-by: Dominique Pellé <dominique.pelle@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
2023-09-08patch 9.0.1885: Vim9: no support for abstract methodsv9.0.1885Yegappan Lakshmanan
Problem: Vim9: no support for abstract methods Solution: Add support for defining abstract methods in an abstract class closes: #13044 closes: #13046 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-09-08patch 9.0.1883: Vim9: Calling an interface method using a child object failsv9.0.1883Yegappan Lakshmanan
Problem: Vim9: Calling an interface method using a child object fails Solution: Search methods of parent class When a class implementing an interface is extended by another class and a child class instance is passed to a function that accepts the interface, calling an interface method doesn't work properly. closes: #13053 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-09-06patch 9.0.1880: Vim9: Need more tests for inheritancev9.0.1880Ernie Rael
Problem: Vim9: Need more tests for inheritance Solution: Add access tests and fixes. `inside_class` fix from yegappan. `object_index_from_itf_index` fix access of member on class extending class implementing interface. Based on tests from Vim9: Class/Object member variable access control #12979 closes: #13032 related: #12979 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Ernie Rael <errael@raelity.com> Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-09-06patch 9.0.1879: Vim9: incorrect duplicate class member detectionv9.0.1879Yegappan Lakshmanan
Problem: Vim9: incorrect duplicate class member detection Solution: Incorrect duplicate class member detection when variable names have the same prefix. Not able to access class member variables using an object. Fix coding style issues closes: #13042 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.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-09-01patch 9.0.1838: Vim9: Cannot modify class member vars from def functionv9.0.1838Yegappan Lakshmanan
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-08-31patch 9.0.1831: Vim9: failing null testv9.0.1831Gianmaria Bajo
Problem: Vim9: failing null test Solution: Use required public keyword closes: #12982 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Gianmaria Bajo <mg1979.git@gmail.com>
2023-08-31patch 9.0.1830: Vim9: crash when accessing a null objectv9.0.1830Gianmaria Bajo
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-31patch 9.0.1829: Vim9 missing access-checks for private varsv9.0.1829Yegappan Lakshmanan
Problem: Vim9 missing access-checks for private vars Solution: Use the proper check for private/readonly variable. Access level for a member cannot be changed in a class implementing an interface. Update the code indentation closes: #12978 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com> Co-authored-by: Ernie Rael <errael@raelity.com>
2023-08-30patch 9.0.1824: Vim9: private members may be modifiablev9.0.1824Yegappan Lakshmanan
Problem: Vim9: private members may be modifiable Solution: prevent modification for def function closes: #12963 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-08-29patch 9.0.1822: Vim9: no check for duplicate members in extended classesv9.0.1822Yegappan Lakshmanan
Problem: Vim9: no check for duplicate members in extended classes Solution: Check for duplicate members in extended classes. Fix memory leak. closes: #12948 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-08-29patch 9.0.1821: Vim9 constructors are always staticv9.0.1821Gianmaria Bajo
Problem: Vim9 constructors are always static Solution: make the "static" keyword an error closes: #12945 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Gianmaria Bajo <mg1979.git@gmail.com>
2023-08-28patch 9.0.1814: Vim9 no error on duplicate object member varv9.0.1814Yegappan Lakshmanan
Problem: Vim9 no error on duplicate object member var Solution: detect duplicate members and error out closes: #12938 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-08-27patch 9.0.1805: Vim9: problem compiling object method as function call argv9.0.1805Yegappan Lakshmanan
Problem: Vim9: problem compiling object method as function call arg Solution: After a object/class method call, remove the object/class from the stack. closes: #12081 closes: #12929 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-08-27patch 9.0.1804: Vim9: no support for private object methodsv9.0.1804Yegappan Lakshmanan
Problem: Vim9: no support for private object methods Solution: Add support for private object/class methods closes: #12920 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-08-27patch 9.0.1801: Vim9 instanceof() fails in a def funcv9.0.1801Yegappan Lakshmanan
Problem: Vim9 instanceof() fails in a def func Solution: allow Objects in compile time check closes: #12907 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-08-27patch 9.0.1796: Vim9 problems with null_objectsv9.0.1796Ernie Rael
Problem: Vim9 problems with null_objects Solution: Vim9 improve null_object usage Fix "xvar == null", where xvar might have been assigned null_object. Fix compilation failure: "var o2: C = null_object". closes: #12890 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Ernie Rael <errael@raelity.com>
2023-08-23patch 9.0.1786: Vim9: need instanceof() functionv9.0.1786LemonBoy
Problem: Vim9: need instanceof() function Solution: Implement instanceof() builtin Implemented in the same form as Python's isinstance because it allows for checking multiple class types at the same time. closes: #12867 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: LemonBoy <thatlemon@gmail.com>
2023-08-22patch 9.0.1780: Vim9 type not defined during object creationv9.0.1780Yegappan Lakshmanan
Problem: Vim9 type not defined during object creation Solution: Define type during object creation and not during class definition, parse mulit-line member initializers, fix lock initialization If type is not specified for a member, set it during object creation instead of during class definition. Add a runtime type check for the object member initialization expression Also, while at it, when copying an object or class, make sure the lock is correctly initialized. And finally, parse multi-line member initializers correctly. closes: #11957 closes: #12868 closes: #12869 closes: #12881 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com> Co-authored-by: LemonBoy <thatlemon@gmail.com>
2023-08-20patch 9.0.1760: vim9 class problem with new() constructorv9.0.1760Yegappan Lakshmanan
Problem: vim9 class problem with new() constructor Solution: Don't allow a return type for the new() class constructor. closes: #12863 closes: #12040 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-08-20patch 9.0.1758: vim9 no class identifiers in stack dumpsv9.0.1758LemonBoy
Problem: vim9 no class identifiers in stack dumps Solution: Prefix class members in stack traces with the class name followed by a dot. closes: #12866 closes: #12078 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: LemonBoy <thatlemon@gmail.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-19patch 9.0.1737: Calling a base class method through an extended class failsv9.0.1737Yegappan Lakshmanan
Problem: Calling a base class method through an extended class fails Solution: Create lookup table for member index in the interface to to the member class implementing the interface Create additional tests for Vim9 classes. Fix unconvered memory leaks and crashes found by the new tests. closes: #12848 closes: #12089 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>author
2023-08-17patch 9.0.1724: vim9class constructor argument type checking bugv9.0.1724h-east
Problem: vim9class constructor argument type checking bug Solution: fix it closes: #12816 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: h-east <h.east.727@gmail.com>
2023-08-16patch 9.0.1720: Vim9 class using wrong index for overridden methodv9.0.1720Yegappan Lakshmanan
Problem: Vim9 class using wrong index for overridden method Solution: Use correct index for overridden method closes: #12524 closes: #12813 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-08-13patch 9.0.1703: Vim9 Calling a method in an extended class failsv9.0.1703Yegappan Lakshmanan
Problem: Vim9 Calling a method in an extended class fails Solution: use method index directly closes: #12778 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-08-13patch 9.0.1701: vim9 crash when class member overriddenv9.0.1701Yegappan Lakshmanan
Problem: vim9 crash when class member overridden Solution: Use method_count field instead closes: #12676 closes: #12677 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-06-24patch 9.0.1662: crash when using a class member twicev9.0.1662Bram Moolenaar
Problem: Crash when using a class member twice. (Christian J. Robinson) Solution: Make a copy of the value.
2023-06-10patch 9.0.1624: crash when calling object constructorv9.0.1624Bram Moolenaar
Problem: Crash when calling object constructor from legacy script. (Israel Chauca Fuentes) Solution: Pass a pointer for "ufunc". (closes #12502)
2023-06-05patch 9.0.1609: crash when an object indirectly references itselfv9.0.1609Bram Moolenaar
Problem: Crash when an object indirectly references itself. Solution: Avoid clearing an object while it is already being cleared. (closes #12494)
2023-06-04patch 9.0.1605: crash when calling method on super in child constructorv9.0.1605Ernie Rael
Problem: Crash when calling method on super in child constructor. (Israel Chauca Fuentes) Solution: Clear the type list. (Ernie Rael, closes #12489, closes #12471)