HaxeFoundation / HaxeFoundation/haxe

Monomorph constraints for operators

Open
#9,553 1 comment 1 reaction 0 assignees View on GitHub
feature-type-inference
Dominant language
Haxe
Stars
6.9k
Forks
715
Avg merge
2d 2h
Merged PRs (30d)
11

Description

With the new fancy constrained monomorph, I believe it is possible to support this:

```haxe
abstract A({}) {
@:op([]) function get(index:Int):A return null;
@:op(a+b) function add(other:A):A return null;
}

function main() {
var x = null;
var y = x + x;
(x : A); // Int should be A

var x = null;
x[0];
(x : A); // Array> should be A
}
```

Contributor guide

Open the contributing guide

Research direction

No files, tests, or entry points are named. Start by reproducing the constrained-monomorph operator examples from the issue and trace how the compiler handles the null variables, operator calls, and casts. Done means both examples infer the stated types and support the requested operator constraints.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.