소스 검색

add tests for optional structure fields (closes #3814)

Dan Korostelev 10 년 전
부모
커밋
8455f9a15a
1개의 변경된 파일14개의 추가작업 그리고 0개의 파일을 삭제
  1. 14 0
      tests/unit/src/unit/TestBasetypes.hx

+ 14 - 0
tests/unit/src/unit/TestBasetypes.hx

@@ -496,4 +496,18 @@ class TestBasetypes extends Test {
 		var a = new unit.MyAbstract.MySpecialString("My debugging abstract");
 		eq("debugging abstract", a.substr(3));
 	}
+
+	@:analyzer(no_local_dce)
+	function testOptionalStructureFields() {
+		var a:{?f:Int} = {};
+		eq(a.f, null);
+
+		var o:Dynamic = {};
+		var a:{?f:Int} = o;
+		eq(a.f, null);
+
+		var i:Dynamic = 1;
+		var a:{?f:Int} = i;
+		unspec(function() a.f);
+	}
 }