WurstScript icon indicating copy to clipboard operation
WurstScript copied to clipboard

Wrong warning When Abstract functions have the same name.

Open supemeko opened this issue 6 years ago • 3 comments

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()

FOO

supemeko avatar Jun 10 '19 11:06 supemeko

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()

Frotty avatar Jun 20 '19 10:06 Frotty

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()

supemeko avatar Jun 28 '19 14:06 supemeko

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

supemeko avatar Aug 05 '20 04:08 supemeko