HaxeFoundation / HaxeFoundation/haxe

Map with abstract key complains about mismatched types

Open
#11,694 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

# Expected behavior

Given that JobIdentifier is an abstract, I should be able to create the following map:

```haxe
static var callbackHandlers:Map = new Map();
```

# Actual behavior

However, I receive this error:

```
[ERROR] Test.hx:3: characters 60-69

3 | static var callbackHandlers:Map = new Map();
| ^^^^^^^^^
| error: JobIdentifier should be _Test.JobIdentifierImpl
| have: (haxe.IMap<_Test.JobIdentifierImpl, ...>) -> ...
| want: (haxe.IMap) -> ...
```

Using `new Map()` displays the same error.

# Minimal reproduction

https://try.haxe.org/#b85078ba

# Use case

I am using `haxe-concurrent`, and I trying to make a map storing data for each of a set of tasks, identified by their JobIdentifier.

Contributor guide

Open the contributing guide

Research direction

Start by running the minimal reproduction linked in the issue and confirm the type mismatch for Map. Trace the compiler's handling of abstract key types and Map construction, then add or update a focused regression test. Done means the reproduction compiles with the abstract key declaration and existing Map behavior remains intact.

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
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.