@@ -178,13 +178,19 @@ class Printer {
178
178
public function printFunctionArg (arg : FunctionArg )
179
179
return (arg .opt ? "?" : "") + arg .name + opt (arg .type , printComplexType , " :" ) + opt (arg .value , printExpr , " = " );
180
180
181
- public function printFunction (func : Function )
181
+ public function printFunction (func : Function , ? kind : FunctionKind ) {
182
+ var skipParentheses = switch func .args {
183
+ case [{ type :null }]: kind == FArrow ;
184
+ case _ : false ;
185
+ }
182
186
return (func .params == null ? " " : func .params .length > 0 ? " <" + func .params .map (printTypeParamDecl ).join (" , " ) + " >" : " " )
183
- + " ( "
187
+ + ( skipParentheses ? " " : " ( " )
184
188
+ func .args .map (printFunctionArg ).join (" , " )
185
- + " )"
189
+ + (skipParentheses ? " " : " )" )
190
+ + (kind == FArrow ? " ->" : " " )
186
191
+ opt (func .ret , printComplexType , " :" )
187
192
+ opt (func .expr , printExpr , " " );
193
+ }
188
194
189
195
public function printVar (v : Var )
190
196
return v .name + opt (v .type , printComplexType , " :" ) + opt (v .expr , printExpr , " = " );
@@ -218,7 +224,7 @@ class Printer {
218
224
case EUnop (op , true , e1 ): printExpr (e1 ) + printUnop (op );
219
225
case EUnop (op , false , e1 ): printUnop (op ) + printExpr (e1 );
220
226
case EFunction (FNamed (no ,inlined ), func ): (inlined ? ' inline ' : ' ' ) + ' function $no ' + printFunction (func );
221
- case EFunction (_ , func ): " function" + printFunction (func );
227
+ case EFunction (kind , func ): ( kind != FArrow ? " function" : " " ) + printFunction (func , kind );
222
228
case EVars (vl ): " var " + vl .map (printVar ).join (" , " );
223
229
case EBlock ([]): ' { }' ;
224
230
case EBlock (el ):
@@ -256,6 +262,7 @@ class Printer {
256
262
case EDisplayNew (tp ): ' #DISPLAY( ${printTypePath (tp )})' ;
257
263
case ETernary (econd , eif , eelse ): ' ${printExpr (econd )} ? ${printExpr (eif )} : ${printExpr (eelse )}' ;
258
264
case ECheckType (e1 , ct ): ' ( ${printExpr (e1 )} : ${printComplexType (ct )})' ;
265
+ case EMeta ({ name :" :implicitReturn" }, { expr :EReturn (e1 ) }): printExpr (e1 );
259
266
case EMeta (meta , e1 ): printMetadata (meta ) + " " + printExpr (e1 );
260
267
}
261
268
0 commit comments