Forráskód Böngészése

allow type expressions as constant inline vars (fixed issue #849)

Simon Krajewski 13 éve
szülő
commit
12cfc86635
2 módosított fájl, 5 hozzáadás és 2 törlés
  1. 4 2
      tests/unit/TestMisc.hx
  2. 1 0
      typeload.ml

+ 4 - 2
tests/unit/TestMisc.hx

@@ -291,12 +291,15 @@ class TestMisc extends Test {
 	}
 
 	static inline function foo(x) return x + 5
-
+	static inline var type = String;
+	
 	function testInline() {
 		// check that operations are correctly generated
 		var x = 3; // prevent optimization
 		eq( 2 * foo(x), 16 );
 		eq( -foo(x), -8 );
+		
+		t(Std.is(Type.createEmptyInstance(type), String));
 	}
 
 	function testEvalAccessOrder() {
@@ -402,5 +405,4 @@ class TestMisc extends Test {
 		eq( haxe.Json.parse('"\\u00E9"'), "é" );
 		
 	}
-	
 }

+ 1 - 0
typeload.ml

@@ -923,6 +923,7 @@ let init_class ctx c p herits fields =
 									| TConst _ -> true
 									| TBinop ((OpAdd|OpSub|OpMult|OpDiv|OpMod),e1,e2) -> is_const e1 && is_const e2
 									| TParenthesis e -> is_const e
+									| TTypeExpr _ -> true
 									| _ -> false
 								in
 								if not (is_const e) then display_error ctx "Inline variable must be a constant value" p;