HaxeFoundation / HaxeFoundation/haxe

@:pos vs display type

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

Description

The following code:
```haxe
macro @:pos(pos) var foo : foo.Bar<$whatever> = bar;
```

Will create an expression with a `TypePath` that has `pos` as position.

This will be an issue in some (admittedly niche) cases where this expression ends up being loaded before the actual display type, because compiler will enter `load_instance` with that type path, and call `display_type` for `foo.Bar` if `pos` encloses the actual display position (which can happen when using positions like class position or field position for generated expressions, _which should probably be avoided in the first place_).

It seems this is not easy to fix, because setting `pos` to the `TypePath` here is wanted behavior for `@:genericBuild` at least.

Contributor guide

Open the contributing guide

Research direction

Start by tracing how a TypePath with a macro @:pos position reaches load_instance and then display_type for foo.Bar. Compare this with the position behavior required by @:genericBuild, and examine cases where generated expressions use class or field positions. Done means the conflicting position behavior and a compatible resolution are established.

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.