HaxeFoundation / HaxeFoundation/haxe

`-D no-inline` breaks map literals in HashLink

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

Description

Edit: [See my reply below for a minimal example](#issuecomment-1368156306).

---

I'm trying to [build the Lime tools for HL](https://github.com/HaxeFoundation/haxe/blob/development/src/generators/genhl.ml#L519), but it gives me an `Invalid_argument("List.map2")` error. Using `OCAMLRUNPARAM=b` I was able to track it down to [genhl.ml line 519](https://github.com/HaxeFoundation/haxe/blob/development/src/generators/genhl.ml#L519), but that's not very helpful.

I would absolutely love to give you a minimal example, but the error message isn't specific enough for me to narrow it down.

When I have more time, I think my plan is to insert a temporary `try` block in genhl.ml so I can get `e.epos` (which I would use to narrow the error down). But I have no Ocaml experience, so I was hoping someone else could tell me how to print that data. This is my best attempt at the code:

```diff
- TFun (List.map2 (fun ((name,opt,t) as a) ((_,_,t2) as a2) ->
+ try TFun (List.map2 (fun ((name,opt,t) as a) ((_,_,t2) as a2) ->
match t, t2 with
(*
Handle function variance:
If we have type parameters which are function types, we need to keep the functions
because we might need to insert a cast to coerce Void->Bool to Void->Dynamic for instance.
*)
| TInst ({cl_kind=KTypeParameter _},_), TFun _ -> a2
(*
If we have a number, it is more accurate to cast it to the type parameter before wrapping it as dynamic
Ignore dynamic method (#7166)
*)
| TInst ({cl_kind=KTypeParameter _},_), t when is_number (to_type ctx t) && (match f with FInstance (_,_,{ cf_kind = Var _ | Method MethDynamic }) -> false | _ -> true) ->
(name, opt, TAbstract (fake_tnull,[t]))
| _ ->
- a
+ a with
+ Invalid_argument -> print_endline e.epos; None
```

Contributor guide

Open the contributing guide

Research direction

Start with the minimal example linked in the issue and reproduce the Lime tools for HashLink build using `-D no-inline`. Read `src/generators/genhl.ml` at line 519 and investigate the `Invalid_argument("List.map2")` failure; done means the map-literal case no longer breaks the build.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.