Browse Source

Don't lose first parameter type (closes #6274) (#6277)

* fix lost first parameter type (closes #6274)

* fix whitespace
ousado 8 years ago
parent
commit
168852ba30
2 changed files with 5 additions and 2 deletions
  1. 2 1
      src/syntax/parser.mly
  2. 3 1
      tests/unit/src/unit/TestArrowFunctions.hx

+ 2 - 1
src/syntax/parser.mly

@@ -1393,7 +1393,8 @@ and expr = parser
 			| [< t,pt = parse_type_hint_with_pos; s >] -> (match s with parser
 				| [< '(PClose,p2); s >] -> expr_next (EParenthesis (ECheckType(e,(t,pt)),punion p1 p2), punion p1 p2) s
 				| [< '(Comma,pc); al = psep Comma parse_fun_param; '(PClose,_); er = arrow_expr; s >] ->
-					arrow_function p1 ((arrow_first_param e) :: al) er
+					let (np,_) = arrow_ident_checktype e in
+					arrow_function p1 ((np,false,[],(Some(t,pt)),None) :: al) er
 				| [< '((Binop OpAssign),p2); ea1 = expr; s >] ->
 					let with_args al er = (match fst e with
 						| EConst(Ident n) ->

+ 3 - 1
tests/unit/src/unit/TestArrowFunctions.hx

@@ -24,7 +24,7 @@ class TestArrowFunctions extends Test {
 	var f6_b: Int->(Int->(Int->Int));
 	var f7:   (Int->Int)->(Int->Int);
 	var f8:   Int -> String;
-
+	var f9:   Float->Bool->String;
 	var arr: Array<Int->Int> = [];
 	var map: Map<Int,Int->Int> = new Map();
 	var obj: { f : Int->Int };
@@ -135,6 +135,8 @@ class TestArrowFunctions extends Test {
 		};
 
 		f8 = (a:Int) -> ('$a':String);
+		var _f9 = (a:Float,b:Bool) -> '$a $b';
+		f9 = _f9;
 
 		arr = [for (i in 0...5) a -> a * i];
 		arr = [a -> a + a, b -> b + b, c -> c + c];