瀏覽代碼

added error on problematic _ usage on flash9

Simon Krajewski 13 年之前
父節點
當前提交
511c76bbc1
共有 2 個文件被更改,包括 6 次插入0 次删除
  1. 4 0
      tests/unit/TestType.hx
  2. 2 0
      typer.ml

+ 4 - 0
tests/unit/TestType.hx

@@ -270,8 +270,12 @@ class TestType extends Test {
 
 
 		// TODO: this fails on flash 9
 		// TODO: this fails on flash 9
 		var foo = function(bar = 2) { return bar; };
 		var foo = function(bar = 2) { return bar; };
+		#if flash9
+		t(typeError(callback(foo, _)));
+		#else
 		var l = callback(foo, _);
 		var l = callback(foo, _);
 		eq(2, l());
 		eq(2, l());
+		#end
 		
 		
 		// note that this does not
 		// note that this does not
 		var foo = function(bar:Null<Int> = 2) { return bar; };
 		var foo = function(bar:Null<Int> = 2) { return bar; };

+ 2 - 0
typer.ml

@@ -826,6 +826,8 @@ let type_callback ctx e params p =
 				| _ -> ordered_args
 				| _ -> ordered_args
 			in
 			in
 			loop args [] given_args missing_args a
 			loop args [] given_args missing_args a
+		| (n,o,t) :: _ , (EConst(Ident "_"),p) :: _ when ctx.com.platform = Flash && o && not (is_nullable t) ->
+			error "Usage of _ is currently not supported for optional non-nullable arguments on flash9" p
 		| (n,o,t) :: args , ([] as params)
 		| (n,o,t) :: args , ([] as params)
 		| (n,o,t) :: args , (EConst(Ident "_"),_) :: params ->
 		| (n,o,t) :: args , (EConst(Ident "_"),_) :: params ->
 			let v = alloc_var (alloc_name n) t in
 			let v = alloc_var (alloc_name n) t in