HaxeFoundation / HaxeFoundation/haxe
[python] Closure calls on String cause problems due to optimization
- Dominant language
- Haxe
- Stars
- 6.9k
- Forks
- 715
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 11
Description
``` haxe
class Main {
static function main() {
("foo".toUpperCase)();
}
}
```
Output:
``` python
@staticmethod
def main():
"foo".toUpperCase()
```
This is a bit funny. It happens because of an optimization case in `reduce_loop`:
``` ocaml
| TCall ({ eexpr = TField (o,FClosure (c,cf)) } as f,el) ->
let fmode = (match c with None -> FAnon cf | Some (c,tl) -> FInstance (c,tl,cf)) in
{ e with eexpr = TCall ({ f with eexpr = TField (o,fmode) },el) }
```
What this doesn't account for is the fact that the class field in question may be `inline` and even `extern`, as is the case with `String.toUpperCase` on python. While genpy knows how to handle the FClosure case, it does not know what to do with the FInstance one because that usually never happens.
I'm not quite sure where to fix this right now.
Contributor guide
Assessment
This issue has not been assessed yet.