فهرست منبع

[hxb] fix gadt

Rudy Ges 2 سال پیش
والد
کامیت
da357fb366

+ 16 - 3
src/compiler/hxb/hxbReader.ml

@@ -630,9 +630,22 @@ class hxb_reader
 			let tl = self#read_types in
 			TEnum(e,tl)
 		| 16 ->
-			let t = self#read_typedef_ref in
-			let tl = self#read_types in
-			TType(t,tl)
+			begin match self#read_u8 with
+				| 0 ->
+					let an = mk_anon (ref Closed) in
+					let tl = self#read_types in
+					let td = { null_typedef with t_type = an } in
+					TType(td,tl)
+				| 1 ->
+					let an = TAnon self#read_anon_ref in
+					let tl = self#read_types in
+					let td = { null_typedef with t_type = an } in
+					TType(td,tl)
+				| _ ->
+					let t = self#read_typedef_ref in
+					let tl = self#read_types in
+					TType(t,tl)
+			end
 		| 17 ->
 			let a = self#read_abstract_ref in
 			let tl = self#read_types in

+ 13 - 3
src/compiler/hxb/hxbWriter.ml

@@ -385,9 +385,19 @@ class ['a] hxb_writer
 			self#write_types tl
 		| TType(td,tl) ->
 			chunk#write_byte 16;
-			(* Printf.eprintf "  TType %d for %s\n" 16 (s_type_path td.t_path); *)
-			self#write_typedef_ref td;
-			self#write_types tl
+			begin match td.t_type with
+				| TAnon an when PMap.is_empty an.a_fields ->
+					chunk#write_byte 0;
+					self#write_types tl
+				| TAnon an ->
+					chunk#write_byte 1;
+					self#write_anon_ref an;
+					self#write_types tl
+				| _ ->
+					chunk#write_byte 2;
+					self#write_typedef_ref td;
+					self#write_types tl
+			end;
 		| TAbstract(a,tl) ->
 			chunk#write_byte 17;
 			self#write_abstract_ref a;

+ 2 - 2
tests/unit/src/unit/TestMain.hx

@@ -69,7 +69,7 @@ function main() {
 		new TestMeta(),
 		new TestType(),
 		new TestOrder(),
-		// new TestGADT(), // Cannot resolve type unit.TestGADT.Enum<unit.Expr>
+		new TestGADT(),
 		new TestGeneric(),
 		new TestArrowFunctions(),
 		new TestCasts(),
@@ -81,7 +81,7 @@ function main() {
 		new TestRest(),
 		new TestHttp(),
 		#if !no_pattern_matching
-		// new TestMatch(), // Cannot resolve type unit.TestMatch.Enum<unit.A>
+		new TestMatch(),
 		#end
 		#if cs
 		new TestCSharp(),

+ 0 - 0
tests/unit/src/unit/issues/Issue10291.hx.disabled → tests/unit/src/unit/issues/Issue10291.hx


+ 0 - 0
tests/unit/src/unit/issues/Issue2478.hx.disabled → tests/unit/src/unit/issues/Issue2478.hx


+ 0 - 0
tests/unit/src/unit/issues/Issue2778.hx.disabled → tests/unit/src/unit/issues/Issue2778.hx


+ 0 - 0
tests/unit/src/unit/issues/Issue3513.hx.disabled → tests/unit/src/unit/issues/Issue3513.hx


+ 0 - 0
tests/unit/src/unit/issues/Issue3528.hx.disabled → tests/unit/src/unit/issues/Issue3528.hx


+ 0 - 0
tests/unit/src/unit/issues/Issue3970.hx.disabled → tests/unit/src/unit/issues/Issue3970.hx


+ 0 - 0
tests/unit/src/unit/issues/Issue4287.hx.disabled → tests/unit/src/unit/issues/Issue4287.hx


+ 0 - 0
tests/unit/src/unit/issues/Issue4578.hx.disabled → tests/unit/src/unit/issues/Issue4578.hx


+ 0 - 0
tests/unit/src/unit/issues/Issue4966.hx.disabled → tests/unit/src/unit/issues/Issue4966.hx


+ 0 - 0
tests/unit/src/unit/issues/Issue5064.hx.disabled → tests/unit/src/unit/issues/Issue5064.hx


+ 0 - 0
tests/unit/src/unit/issues/Issue5486.hx.disabled → tests/unit/src/unit/issues/Issue5486.hx


+ 0 - 0
tests/unit/src/unit/issues/Issue6413.hx.disabled → tests/unit/src/unit/issues/Issue6413.hx


+ 0 - 0
tests/unit/src/unit/issues/Issue6561.hx.disabled → tests/unit/src/unit/issues/Issue6561.hx


+ 0 - 0
tests/unit/src/unit/issues/Issue6606.hx.disabled → tests/unit/src/unit/issues/Issue6606.hx


+ 0 - 0
tests/unit/src/unit/issues/Issue7115.hx.disabled → tests/unit/src/unit/issues/Issue7115.hx


+ 0 - 0
tests/unit/src/unit/issues/Issue7672.hx.disabled → tests/unit/src/unit/issues/Issue7672.hx


+ 0 - 0
tests/unit/src/unit/issues/Issue8296.hx.disabled → tests/unit/src/unit/issues/Issue8296.hx


+ 0 - 0
tests/unit/src/unit/issues/Issue8959.hx.disabled → tests/unit/src/unit/issues/Issue8959.hx


+ 0 - 0
tests/unit/src/unit/issues/Issue9577.hx.disabled → tests/unit/src/unit/issues/Issue9577.hx


+ 0 - 0
tests/unit/src/unit/issues/Issue9828.hx.disabled → tests/unit/src/unit/issues/Issue9828.hx


+ 2 - 2
tests/unit/src/unitstd/Std.unit.hx

@@ -55,8 +55,8 @@ Std.string(cwts) == "ClassWithToString.toString()";
 Std.string(cwtsc) == "ClassWithToString.toString()";
 Std.string(cwtsc2) == "ClassWithToStringChild2.toString()";
 
-// Std.string(SomeEnum.NoArguments) == "NoArguments";
-// Std.string(SomeEnum.OneArgument("foo")) == "OneArgument(foo)";
+Std.string(SomeEnum.NoArguments) == "NoArguments";
+Std.string(SomeEnum.OneArgument("foo")) == "OneArgument(foo)";
 
 Std.string(null) == "null";