Parcourir la source

support field display without expressions

Simon Krajewski il y a 9 ans
Parent
commit
09b336ba2e
2 fichiers modifiés avec 4 ajouts et 1 suppressions
  1. 1 1
      src/typing/typeload.ml
  2. 3 0
      tests/display/src/cases/Basic.hx

+ 1 - 1
src/typing/typeload.ml

@@ -2173,7 +2173,7 @@ module ClassInitializer = struct
 
 
 		match e with
 		match e with
 		| None ->
 		| None ->
-			()
+			if fctx.is_display_field then check_field_display ctx (cf.cf_name_pos) cf;
 		| Some e ->
 		| Some e ->
 			if requires_value_meta ctx.com (Some c) then cf.cf_meta <- ((Meta.Value,[e],null_pos) :: cf.cf_meta);
 			if requires_value_meta ctx.com (Some c) then cf.cf_meta <- ((Meta.Value,[e],null_pos) :: cf.cf_meta);
 			let check_cast e =
 			let check_cast e =

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

@@ -66,6 +66,8 @@ class Basic extends DisplayTestCase {
 
 
 		var x4(default, null) = "fo{-4-}";
 		var x4(default, null) = "fo{-4-}";
 		static var x5(default, null) = "fo{-5-}";
 		static var x5(default, null) = "fo{-5-}";
+
+		static var x{-6-}6:String;
 	}
 	}
 	**/
 	**/
 	function testFieldDisplay() {
 	function testFieldDisplay() {
@@ -74,6 +76,7 @@ class Basic extends DisplayTestCase {
 		eq("String", type(pos(3)));
 		eq("String", type(pos(3)));
 		eq("String", type(pos(4)));
 		eq("String", type(pos(4)));
 		eq("String", type(pos(5)));
 		eq("String", type(pos(5)));
+		eq("String", type(pos(6)));
 	}
 	}
 
 
 	/**
 	/**