Переглянути джерело

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
 		var foo = function(bar = 2) { return bar; };
+		#if flash9
+		t(typeError(callback(foo, _)));
+		#else
 		var l = callback(foo, _);
 		eq(2, l());
+		#end
 		
 		// note that this does not
 		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
 			in
 			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 , (EConst(Ident "_"),_) :: params ->
 			let v = alloc_var (alloc_name n) t in