WurstScript
WurstScript copied to clipboard
Wrong warning When Abstract functions have the same name.
Describe the bug A clear and concise description of what the bug is.
abstract class A
abstract function foo(int i)
abstract function foo()
abstract class B extends A
override function foo(int i)
foo()

You can't call an abstract function. Maybe your example is incomplete. This works:
abstract class A
abstract function foo(int i)
abstract function foo()
abstract class B extends A
override function foo(int i)
foo()
override function foo()
This also works, but probably shouldn't
abstract class A
abstract function foo(int i)
abstract function foo()
abstract class B extends A
override function foo(int i)
super.foo()
but this is error:
abstract class A
abstract function foo(int i)
abstract function foo()
abstract class B extends A
override function foo(int i)
foo()
class C extends B
override function foo()
Just happens when functions have the same name, If you use another name, It’s right like this:
abstract class A
abstract function foo(int i)
abstract function foo2()
abstract class B extends A
override function foo(int i)
foo2()
class A
function func(int i)
print("func_int...")
function func(string s)
print("func_string...")
class B extends A
function func()
print("func_noarg")
function func(bool b)
print("func_boolean...")
init
let b = new B()
b.func()
b.func(true)
b.func(1) //Too many arguments: 1 given, but only 0 expected.
b.func("1") //Too many arguments: 1 given, but only 0 expected.
when a class extends another class and this class own a function as the same name as super class , this class will lose other same name function of super class.
class A
function func(int i)
print("func_int...")
class B extends A
function func()
print("func_noarg")
init
let b = new B()
b.func()
b.func(1) //Too many arguments: 1 given, but only 0 expected.
The previous code was pasted incorrectly :X