@@ -1364,6 +1364,7 @@ object Parsers {
1364
1364
val start = in.offset
1365
1365
var imods = Modifiers ()
1366
1366
def functionRest (params : List [Tree ]): Tree =
1367
+ val paramSpan = Span (start, in.lastOffset)
1367
1368
atSpan(start, in.offset) {
1368
1369
if in.token == TLARROW then
1369
1370
if ! imods.flags.isEmpty || params.isEmpty then
@@ -1382,14 +1383,16 @@ object Parsers {
1382
1383
accept(ARROW )
1383
1384
val t = typ()
1384
1385
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
1387
1391
val (newParams :+ newT, tparams) = replaceKindProjectorPlaceholders(params :+ t)
1388
1392
1389
1393
lambdaAbstract(tparams, Function (newParams, newT))
1390
- } else {
1394
+ else
1391
1395
Function (params, t)
1392
- }
1393
1396
}
1394
1397
def funArgTypesRest (first : Tree , following : () => Tree ) = {
1395
1398
val buf = new ListBuffer [Tree ] += first
@@ -2183,7 +2186,12 @@ object Parsers {
2183
2186
2184
2187
def closureRest (start : Int , location : Location , params : List [Tree ]): Tree =
2185
2188
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 )
2187
2195
Function (params, if (location == Location .InBlock ) block() else expr())
2188
2196
}
2189
2197
0 commit comments