HaxeFoundation / HaxeFoundation/haxe
Call identifier typed as `AKExpr` instead of `AKField`
- Dominant language
- Haxe
- Stars
- 6.9k
- Forks
- 715
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 11
Description
```haxe
typedef Foo = {
?foo:Int,
?bar:() -> Void,
}
class Main {
static function main() {
test({f|
bar: () -> {
var temp = 0;
// return;
},
});
}
static function test(obj:Foo):Void {}
}
```
If i set cursor after `test({` and type `f`, `test` ident will not be found in cl_statics there and fallback from `AKField` to `AKExpr`:
https://github.com/HaxeFoundation/haxe/blob/3984f2b10db7f099f740382b8e85a2ae96eba514/src/typing/typer.ml#L338
But if i uncomment `return` or comment `temp` var line, it will find `test` static field. Is this somewhat expected?
Basically it losts `with_type` for `EBlock` anon struct, so i cannot type it as `TObjectDecl`. It also works if i move `test` declaration before `main`. Same behavior happens for non-statics.
Contributor guide
Research direction
Reproduce the completion behavior with the Haxe snippet, comparing the versions with and without the return or temp variable. Start at src/typing/typer.ml around line 338 and trace how the anonymous struct EBlock loses with_type and falls back from AKField to AKExpr. Done means the cursor after test({ resolves the test identifier consistently in the reported cases.
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
- Mostly clear
- Newbie friendliness
- 45/100