haxe-instrument icon indicating copy to clipboard operation
haxe-instrument copied to clipboard

Does not work on module-level fields

Open ALANVF opened this issue 3 years ago • 2 comments

Even when excluding the package/file and adding the "ignore" metadata, profiling a project with files with module-level fields will error with a message like:

src/util/ImmutableMap.hx:61: character 9 : util._ImmutableMap.ImmutableMap_Fields_ is not ready to be accessed, separate your type declarations in several files

repeated over and over again. putting these fields in a separate type fixes this, but I'd rather not do that for every file lol.

Here's an example file: https://github.com/ALANVF/star/blob/master/src/util/ImmutableMap.hx

ALANVF avatar Mar 15 '22 01:03 ALANVF

I'm not sure if there is a way around that message, but it's also not really obvious to figure out what the actual cause is since there are so many different moving parts.

can you reduce it to a smaller test case?

AlexHaxe avatar Mar 15 '22 20:03 AlexHaxe

I think the issue here is that it is trying to access the module-level fields before the type is fully-defined. Assuming the module-level fields are put in a generated type called _ImmutableMap.ImmutableMap_Fields_, it's trying to do stuff with that before doing anything with the other types. I'm not entirely sure how to reduce this to something smaller because I'm not sure which part of it causes this to happen, however I think it's either due to the @:using(<current file type>) metadata or because the main file type has the @:generic metadata

ALANVF avatar Mar 16 '22 05:03 ALANVF