HaxeFoundation / HaxeFoundation/haxe

[python] redundant locals

Open
#5,080 7 comments 0 reactions 1 assignee Claimed by @Simn View on GitHub
platform-python priority-low
Dominant language
Haxe
Stars
6.9k
Forks
715
Avg merge
2d 2h
Merged PRs (30d)
11

Description

as mentioned in #5059, we have some temp var issues in python target:

``` haxe
class Main {
static function main() {
var lines = [""];
lines[0] += "";
trace(lines);
}
}
```

generates this abomination:

``` python
def main():
lines = [""]
_hx_local_0 = lines
_hx_local_1 = 0
_hx_local_2 = (_hx_local_0[_hx_local_1] if _hx_local_1 >= 0 and _hx_local_1 < len(_hx_local_0) else None)
python_internal_ArrayImpl._set(_hx_local_0, _hx_local_1, (("null" if _hx_local_2 is None else _hx_local_2) + ""))
(_hx_local_0[_hx_local_1] if _hx_local_1 >= 0 and _hx_local_1 < len(_hx_local_0) else None)
print(str((("[" + HxOverrides.stringOrNull(",".join([python_Boot.toString1(x1,'') for x1 in lines]))) + "]")))
```

judging by names (`_hx_local`), they are introduced by genpy transformers.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.