1
0
forked from Mirror/wren

Do not allow inheriting built-in classes Num, Bool and Null (#831)

* Do not allow inheriting `Num`, `Bool` and `Null`. fixes #830
This commit is contained in:
Chayim Refael Friedman
2020-10-26 17:39:36 +02:00
committed by GitHub
parent ad4e039187
commit 44d6d20586
4 changed files with 7 additions and 1 deletions

View File

@ -512,7 +512,10 @@ static Value validateSuperclass(WrenVM* vm, Value name, Value superclassValue,
superclass == vm->listClass ||
superclass == vm->mapClass ||
superclass == vm->rangeClass ||
superclass == vm->stringClass)
superclass == vm->stringClass ||
superclass == vm->boolClass ||
superclass == vm->nullClass ||
superclass == vm->numClass)
{
return wrenStringFormat(vm,
"Class '@' cannot inherit from built-in class '@'.",

View File

@ -0,0 +1 @@
class Subclass is Bool {} // expect runtime error: Class 'Subclass' cannot inherit from built-in class 'Bool'.

View File

@ -0,0 +1 @@
class Subclass is Null {} // expect runtime error: Class 'Subclass' cannot inherit from built-in class 'Null'.

View File

@ -0,0 +1 @@
class Subclass is Num {} // expect runtime error: Class 'Subclass' cannot inherit from built-in class 'Num'.