浏览代码

always allow loading types without type parameters in display mode

Simon Krajewski 9 年之前
父节点
当前提交
1ab02dab12
共有 2 个文件被更改,包括 8 次插入1 次删除
  1. 1 1
      src/typing/typeload.ml
  2. 7 0
      tests/display/src/cases/Basic.hx

+ 1 - 1
src/typing/typeload.ml

@@ -428,7 +428,7 @@ let rec load_instance ?(allow_display=false) ctx (t,pn) allow_no_params p =
 		in
 		let types , path , f = ctx.g.do_build_instance ctx mt p in
 		let is_rest = is_generic_build && (match types with ["Rest",_] -> true | _ -> false) in
-		if allow_no_params && t.tparams = [] && not is_rest then begin
+		if (allow_no_params || ctx.com.display <> DMNone) && t.tparams = [] && not is_rest then begin
 			let pl = ref [] in
 			pl := List.map (fun (name,t) ->
 				match follow t with

+ 7 - 0
tests/display/src/cases/Basic.hx

@@ -75,4 +75,11 @@ class Basic extends DisplayTestCase {
 		eq("String", type(pos(4)));
 		eq("String", type(pos(5)));
 	}
+
+	/**
+	var a:Ar{-1-}ray;
+	**/
+	@:funcCode function testMissingParams() {
+		eq("Array<Unknown<0>>", type(pos(1)));
+	}
 }