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:
committed by
GitHub
parent
ad4e039187
commit
44d6d20586
@ -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 '@'.",
|
||||
|
||||
1
test/language/inheritance/inherit_from_bool.wren
Normal file
1
test/language/inheritance/inherit_from_bool.wren
Normal file
@ -0,0 +1 @@
|
||||
class Subclass is Bool {} // expect runtime error: Class 'Subclass' cannot inherit from built-in class 'Bool'.
|
||||
1
test/language/inheritance/inherit_from_null_class.wren
Normal file
1
test/language/inheritance/inherit_from_null_class.wren
Normal file
@ -0,0 +1 @@
|
||||
class Subclass is Null {} // expect runtime error: Class 'Subclass' cannot inherit from built-in class 'Null'.
|
||||
1
test/language/inheritance/inherit_from_num.wren
Normal file
1
test/language/inheritance/inherit_from_num.wren
Normal file
@ -0,0 +1 @@
|
||||
class Subclass is Num {} // expect runtime error: Class 'Subclass' cannot inherit from built-in class 'Num'.
|
||||
Reference in New Issue
Block a user