@@ -1364,6 +1364,7 @@ object Parsers {
13641364 val start = in.offset
13651365 var imods = Modifiers ()
13661366 def functionRest (params : List [Tree ]): Tree =
1367+ val paramSpan = Span (start, in.lastOffset)
13671368 atSpan(start, in.offset) {
13681369 if in.token == TLARROW then
13691370 if ! imods.flags.isEmpty || params.isEmpty then
@@ -1382,14 +1383,16 @@ object Parsers {
13821383 accept(ARROW )
13831384 val t = typ()
13841385
1385- if (imods.isOneOf(Given | Erased )) new FunctionWithMods (params, t, imods)
1386- else if (ctx.settings.YkindProjector .value) {
1386+ if imods.isOneOf(Given | Erased ) then
1387+ if imods.is(Given ) && params.isEmpty then
1388+ syntaxError(" context function types require at least one parameter" , paramSpan)
1389+ new FunctionWithMods (params, t, imods)
1390+ else if ctx.settings.YkindProjector .value then
13871391 val (newParams :+ newT, tparams) = replaceKindProjectorPlaceholders(params :+ t)
13881392
13891393 lambdaAbstract(tparams, Function (newParams, newT))
1390- } else {
1394+ else
13911395 Function (params, t)
1392- }
13931396 }
13941397 def funArgTypesRest (first : Tree , following : () => Tree ) = {
13951398 val buf = new ListBuffer [Tree ] += first
@@ -2183,7 +2186,12 @@ object Parsers {
21832186
21842187 def closureRest (start : Int , location : Location , params : List [Tree ]): Tree =
21852188 atSpan(start, in.offset) {
2186- if in.token == CTXARROW then in.nextToken() else accept(ARROW )
2189+ if in.token == CTXARROW then
2190+ if params.isEmpty then
2191+ syntaxError(" context function literals require at least one formal parameter" , Span (start, in.lastOffset))
2192+ in.nextToken()
2193+ else
2194+ accept(ARROW )
21872195 Function (params, if (location == Location .InBlock ) block() else expr())
21882196 }
21892197
0 commit comments