소스 검색

look at the actual array type in real_type, close #6560

Nicolas Cannasse 7 년 전
부모
커밋
ed7e75afc0
2개의 변경된 파일10개의 추가작업 그리고 2개의 파일을 삭제
  1. 8 0
      src/generators/genhl.ml
  2. 2 2
      tests/unit/src/unit/issues/Issue6560.hx

+ 8 - 0
src/generators/genhl.ml

@@ -520,6 +520,14 @@ and real_type ctx e =
 			| _ -> ft)
 		| TLocal v -> v.v_type
 		| TParenthesis e -> loop e
+		| TArray (arr,_) ->
+			let rec loop t =
+				match follow t with
+				| TInst({ cl_path = [],"Array" },[t]) -> t
+				| TAbstract (a,pl) -> loop (Abstract.get_underlying_type a pl)
+				| _ -> t_dynamic
+			in
+			loop arr.etype
 		| _ -> e.etype
 	in
 	to_type ctx (loop e)

+ 2 - 2
tests/unit/src/unit/issues/Issue6560.hx

@@ -1,7 +1,7 @@
 package unit.issues;
 
 class Issue6560 extends unit.Test {
-    #if !hl
+
     function test() {
         function foo<F>(a:F):Array<F> {
             if (false) foo(1);
@@ -10,5 +10,5 @@ class Issue6560 extends unit.Test {
         var bar:Array<Int> = foo(1);
         eq(0, bar.length);
     }
-    #end
+
 }