Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function overload error: Function error filtering in Receiver Type #964

Open
supemeko opened this issue Aug 6, 2020 · 2 comments
Open
Labels

Comments

@supemeko
Copy link

supemeko commented Aug 6, 2020

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.

Originally posted by @supemeko in #863 (comment)

@supemeko
Copy link
Author

supemeko commented Aug 6, 2020

Maybe I can add conditions to fix it
QQ截图20200806113017

@supemeko
Copy link
Author

supemeko commented Aug 6, 2020

When I tried to fix it, cause exception

You encountered a bug in the interpreter: java.lang.Error: wrong number of parameters when calling func B_func(B546_1, 1)
at supemeko line 10

Stack trace:
at : supemeko, line 10
... when calling init_test() in supemeko:1
... when calling main()

at de.peeeq.wurstscript.intermediatelang.interpreter.ILInterpreter.runFunc(ILInterpreter.java:118)
at de.peeeq.wurstscript.intermediatelang.interpreter.EvaluateExpr.evaluateFunc(EvaluateExpr.java:46)
at de.peeeq.wurstscript.intermediatelang.interpreter.EvaluateExpr.eval(EvaluateExpr.java:207)
at de.peeeq.wurstscript.jassIm.ImMethodCallImpl.evaluate(ImMethodCallImpl.java:252)
at de.peeeq.wurstscript.intermediatelang.interpreter.RunStatement.run(RunStatement.java:16)
at de.peeeq.wurstscript.jassIm.ImMethodCallImpl.runStatement(ImMethodCallImpl.java:248)
at de.peeeq.wurstscript.intermediatelang.interpreter.RunStatement.run(RunStatement.java:69)
at de.peeeq.wurstscript.jassIm.ImStmtsImpl.runStatements(ImStmtsImpl.java:84)
at de.peeeq.wurstscript.intermediatelang.interpreter.ILInterpreter.runFunc(ILInterpreter.java:96)
at de.peeeq.wurstscript.intermediatelang.interpreter.EvaluateExpr.evaluateFunc(EvaluateExpr.java:46)
at de.peeeq.wurstscript.intermediatelang.interpreter.EvaluateExpr.evaluateFunc(EvaluateExpr.java:41)
at de.peeeq.wurstscript.intermediatelang.interpreter.EvaluateExpr.eval(EvaluateExpr.java:32)
at de.peeeq.wurstscript.jassIm.ImFunctionCallImpl.evaluate(ImFunctionCallImpl.java:246)
at de.peeeq.wurstscript.intermediatelang.interpreter.RunStatement.run(RunStatement.java:16)
at de.peeeq.wurstscript.jassIm.ImFunctionCallImpl.runStatement(ImFunctionCallImpl.java:242)
at de.peeeq.wurstscript.intermediatelang.interpreter.RunStatement.run(RunStatement.java:69)
at de.peeeq.wurstscript.jassIm.ImStmtsImpl.runStatements(ImStmtsImpl.java:84)
at de.peeeq.wurstscript.intermediatelang.interpreter.ILInterpreter.runFunc(ILInterpreter.java:96)
at de.peeeq.wurstscript.intermediatelang.interpreter.ILInterpreter.executeFunction(ILInterpreter.java:193)
at tests.wurstscript.tests.WurstScriptTest.executeImProg(WurstScriptTest.java:558)
at tests.wurstscript.tests.WurstScriptTest.translateAndTest(WurstScriptTest.java:475)
at tests.wurstscript.tests.WurstScriptTest.testWithoutInliningAndOptimization(WurstScriptTest.java:386)
at tests.wurstscript.tests.WurstScriptTest.access$000(WurstScriptTest.java:38)
at tests.wurstscript.tests.WurstScriptTest$TestConfig.testScript(WurstScriptTest.java:198)
at tests.wurstscript.tests.WurstScriptTest$TestConfig.run(WurstScriptTest.java:128)
at tests.wurstscript.tests.WurstScriptTest$TestConfig.lines(WurstScriptTest.java:118)
at tests.wurstscript.tests.WurstScriptTest.testAssertOkLines(WurstScriptTest.java:311)
at tests.wurstscript.tests.ClassesTests.supemeko(ClassesTests.java:1314)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:124)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:583)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:719)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:989)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
at org.testng.TestRunner.privateRun(TestRunner.java:648)
at org.testng.TestRunner.run(TestRunner.java:505)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:455)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:450)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:415)
at org.testng.SuiteRunner.run(SuiteRunner.java:364)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:84)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1208)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1137)
at org.testng.TestNG.runSuites(TestNG.java:1049)
at org.testng.TestNG.run(TestNG.java:1017)
at org.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:72)
at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:123)

Caused by: java.lang.Error: wrong number of parameters when calling func B_func(B546_1, 1)
at de.peeeq.wurstscript.intermediatelang.interpreter.ILInterpreter.runFunc(ILInterpreter.java:64)
... 51 more

@Frotty Frotty added the bug label Nov 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants