Great! Thanks for the quick reply. I have been able to add a new test in that folder and verified that it does not pass.
Do you think the following would be an improvement?
func-max-args.scala:1: error: Functions can not have more than 26 arguments
trait T { val x: (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z) => Int }
^
one error found
Or do we want something more prescriptive than this?
Also, looking at the code, the chain of function calls that causes this looks like the following:
scala.tools.nsc.ast.parser.Parsers -> scala.tools.nsc.ast.parser.TreeBuilder.makeFunctionTypeTree -> scala.reflect.internal.TreeGen.mkFunctionTypeTree
It looks like the transformation is happening in TreeGen.mkFunctionTypeTree
and this is bubbling up to Parsers, which is why the error message is so strange. I think the best thing to do would be to handle this case explicitly in Parsers as that seems to be the place where most errors are caught explicitly. I think the easiest way is to add a helper function in Parsers
to check the length of the argument list and to throw an error if this is above the threshold. This will require changing a few calls to TreeBuilder.makeFunctionTypeTree
in Parsers
but I think it should not be too bad.
Does this sound reasonable?