Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/generators/genhl.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2332,7 +2332,9 @@ and eval_expr ctx e =
)
| TField (ec,FInstance({ cl_path = [],"Array" },[t],{ cf_name = "length" })) when to_type ctx t = HDyn ->
let r = alloc_tmp ctx HI32 in
op ctx (OCall1 (r,alloc_fun_path ctx (["hl";"types"],"ArrayDyn") "get_length", eval_null_check ctx ec));
let a = eval_to ctx ec (class_type ctx ctx.array_impl.adyn [] false) in
op ctx (ONullCheck a);
op ctx (OCall1 (r, alloc_fun_path ctx (["hl";"types"],"ArrayDyn") "get_length", a));
r
| TField (ec,a) ->
let r = alloc_tmp ctx (to_type ctx (field_type ctx a e.epos)) in
Expand Down
29 changes: 29 additions & 0 deletions tests/unit/src/unit/issues/Issue12380.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package unit.issues;

using Issue12380.ArrayExtensions;
private class ArrayExtensions {
public static inline function isEmpty(a : Array<Any>) : Bool {
return a.length == 0;
}
}

@:forward(push)
private abstract IPolygon(Array<IPoint>) from Array<IPoint> to Array<IPoint> {
}

private class IPoint {
public var x : Int;
public var y : Int;
public inline function new(x = 0, y = 0) {
this.x = x;
this.y = y;
}
}

class Issue12380 extends Test {
function test() {
var shape : IPolygon = [];
shape.push(new IPoint(0, 1));
f(shape.isEmpty());
}
}