HaxeFoundation / HaxeFoundation/haxe
[python] RuntimeError when returning result of assignment to super.method()
- Dominant language
- Haxe
- Stars
- 6.9k
- Forks
- 715
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 11
Description
```haxe
class Main {
static function main() {
Sys.println(new MySubType().set_x(10));
}
}
class MyType {
var x = 0;
public function set_x(n) return x = n * 80;
public function new() {}
}
class MySubType extends MyType {
override function set_x(n) return x = super.set_x(n) + 999;
}
```
Every target (besides python) produces the correct output (this is --interp):
```
PS C:\Users\wavem\source\learnhaxe> haxe build.hxml
1799
```
Compiling to python and running in python 3.8.2 produces this error:
```
C:\Users\wavem\source\learnhaxe> haxe build.hxml; python bin/python/Main.py
Traceback (most recent call last):
File "bin/python/Main.py", line 463, in
Main.main()
File "bin/python/Main.py", line 37, in main
python_Lib.printString((("" + Std.string(MySubType().set_x(10))) + HxOverrides.stringOrNull(python_Lib.lineEnd)))
File "bin/python/Main.py", line 77, in set_x
return _hx_local_1()
File "bin/python/Main.py", line 76, in _hx_local_1
return _hx_local_0()
File "bin/python/Main.py", line 74, in _hx_local_0
self.x = (super().set_x(n) + 999)
RuntimeError: super(): no arguments
```
Note that this only seems to result from expressions of the form `return x = super.set_x(n) + 999;`
If the body of `MySubType.set_x` is changed to:
```haxe
override function set_x(n) {
x = super.set_x(n) + 999;
return x;
}
```
Then it compiles and runs without error in python.
Contributor guide
Assessment
This issue has not been assessed yet.