HaxeFoundation / HaxeFoundation/haxe
[analyzer] returning (const) variable prevents optimization
Open
feature-analyzer
- Dominant language
- Haxe
- Stars
- 6.9k
- Forks
- 715
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 11
Description
```hx
class Test {
static function main() trace(test());
static function test() {
var ret = E.A;
if(ret == E.A) {
return ret;
} else return null;
}
}
enum E { A; B; }
```
Produces:
```js
Test.test = function() {
var ret = E.A;
if(ret == E.A) {
return ret;
} else {
return null;
}
};
```
But changing the `test` body to:
```hx
var ret = E.A;
if(ret == E.A) {
return E.A;
} else return null;
```
Will optimize it down to:
```js
Test.test = function() {
return E.A;
};
```
Contributor guide
Assessment
This issue has not been assessed yet.