HaxeFoundation / HaxeFoundation/haxe

@:keep present while the class is DCEd

Open
#12,300 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Haxe
Stars
6.9k
Forks
715
Avg merge
2d 2h
Merged PRs (30d)
11

Description

When using `-dce full`, some classes seem to received a free `@:keep` meta automatically, while that forced `@:keep` does not have the expected effect: the unused class fields are DCEd.

This does not happen when using default `-dce std` arg

This leads to inconcistency when trying to check for the presence of `@:keep` through RTTI for example: it's appears to be present, but it "didn't work".

HAXE
```haxe
@:rtti class Foo {
public static function main() {
var f = new Foo();
trace( Reflect.hasField(f, "bar") ); // false
trace( haxe.rtti.Rtti.getRtti(Foo).meta ); // @:keep appears here
}

public function new() { }

public function bar() { } // this function is DCEd
}
```

HXML
```hxml
-main Foo
-dce full
```

Contributor guide

Open the contributing guide

Research direction

Reproduce the Haxe example with the shown HXML entry point, comparing -dce full with the default -dce std. Inspect the interaction between Reflect.hasField, haxe.rtti.Rtti.getRtti(Foo), @:keep, and dead-code elimination; done means kept fields remain available and RTTI no longer reports misleading metadata.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.