Generic inline functions are treated as dynamic and crashes when used on maps

Open
#1,007 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
c
Domain
compilers

Research direction

Reproduce with lime test hl -debug -Dhl-check using the generic inline makeSpriteFrom<T:Level> from LDTKBackdrop.hx:23, then reduce it to a minimal Haxe file. The failure comes from the HashLink bytecode checker ("Register 10(dyn) should be object"), so start in this C repo's checker code and the Haxe-to-HL generator that emits the call. Done when the minimal case passes the hl check with the generic inline kept intact.

Written by the indexing model from the issue text.

Description

haxe version: 4.3.7

i have something similar to

var myMap = new Map<String, Sprite>();

for (level in levels)
    myMap.set(level.identifier, makeSpriteFrom(level));

inline function makeSpriteFrom<T:Level>(level:T):Sprite
    return new Sprite(...);

in my code, and for lime on native targets it compiles fine (linux, etc). but for hashlink specifically it errors out

❯ lime test hl -debug -Dhl-check
 ERROR  (unknown position)

   | Error: 
   | levels/loader/parts/LDTKBackdrop.hx:23: Check failure at fun@5689 @1A - Register 10(dyn) should be object

unless i remove the inline from makeSpriteFrom().

it isnt as critical of a bug but its weird that it works on native targets but not hashlink

Dominant language
C
Stars
911
Forks
207
Avg merge
1d 21h
Merged PRs (30d)
13

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from HaxeFoundation/hashlink

All issues in HaxeFoundation/hashlink

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.