feat: prevent subclassing of built-in types with runtime error

Add a check in the interpreter's class creation path that rejects attempts to subclass any of the seven core built-in types (Class, Fiber, Fn, List, Map, Range, String). When such a subclass is declared, a runtime error is raised with a message like "Class 'SubName' may not subclass a built-in". Also add corresponding test files for each forbidden subclass scenario.
This commit is contained in:
Bob Nystrom
2015-02-27 15:41:25 +00:00
9 changed files with 41 additions and 0 deletions
+2
View File
@@ -0,0 +1,2 @@
class SubFiber is Fiber {} // expect runtime error: Class 'SubFiber' may not subclass a built-in