File tree 2 files changed +25
-3
lines changed
compiler/src/dotty/tools/dotc/parsing
tests/neg-custom-args/captures 2 files changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -1648,9 +1648,13 @@ object Parsers {
1648
1648
1649
1649
/** CaptureSet ::= ‘{’ CaptureRef {‘,’ CaptureRef} ‘}’ -- under captureChecking
1650
1650
*/
1651
- def captureSet (): List [Tree ] = inBraces {
1652
- if in.token == RBRACE then Nil else commaSeparated(captureRef)
1653
- }
1651
+ def captureSet (): List [Tree ] =
1652
+ if in.token != LBRACE then
1653
+ syntaxError(em " expected '{' to start capture set " , in.offset)
1654
+ Nil
1655
+ else inBraces {
1656
+ if in.token == RBRACE then Nil else commaSeparated(captureRef)
1657
+ }
1654
1658
1655
1659
def capturesAndResult (core : () => Tree ): Tree =
1656
1660
if Feature .ccEnabled && in.token == LBRACE && canStartCaptureSetContentsTokens.contains(in.lookahead.token)
Original file line number Diff line number Diff line change
1
+ import language .experimental .captureChecking
2
+ import caps .*
3
+
4
+ trait Label extends Capability :
5
+ cap type Fv // the capability set occurring freely in the `block` passed to `boundary` below.
6
+
7
+ def boundary [T , cap C ](block : Label {cap type Fv = {C } } -> {C } T ): T = ??? // link label and block capture set
8
+ def suspend [U ](label : Label )(handler : () -> {label.Fv } U ): U = ??? // note the path
9
+
10
+ def test =
11
+ val x = 1
12
+ boundary : outer =>
13
+ val y = 2
14
+ boundary : inner =>
15
+ val z = 3
16
+ suspend(outer): () =>
17
+ println(inner) // error (leaks the inner label)
18
+ x + y + z
You can’t perform that action at this time.
0 commit comments