@@ -145,7 +145,7 @@ class ParserTests extends munit.FunSuite {
145
145
parse(input, _.externDef())
146
146
147
147
def parseInfo (input : String )(using munit.Location ): Info =
148
- parse(input, _.info(parseCaptures = true ))
148
+ parse(input, _.info())
149
149
150
150
// Custom asserts
151
151
//
@@ -545,6 +545,7 @@ class ParserTests extends munit.FunSuite {
545
545
parseStmts(" val (left, right) = list; return left" )
546
546
547
547
parseStmts(" val g: () => Unit / Exc at {exc} = fun() { closure() }; ()" )
548
+ parseStmts(" val g: () => Unit / Exc at exc = fun() { closure() }; ()" )
548
549
}
549
550
550
551
test(" Pattern-matching val parses with correct span" ) {
@@ -982,6 +983,7 @@ class ParserTests extends munit.FunSuite {
982
983
DefDef (
983
984
IdDef (" foo" , Span (source, pos(0 ), pos(1 ))),
984
985
Maybe .None (Span (source, pos(1 ), pos(1 ))),
986
+ Maybe .None (Span (source, pos(1 ), pos(1 ))),
985
987
Var (IdRef (Nil , " f" , Span (source, pos(2 ), pos(3 ))), Span (source, pos(2 ), pos(3 ))),
986
988
Info .empty(Span (source, 0 , 0 )),
987
989
Span (source, 0 , pos.last)))
@@ -1013,6 +1015,12 @@ class ParserTests extends munit.FunSuite {
1013
1015
)
1014
1016
}
1015
1017
1018
+ test(" Function definition with capture set" ) {
1019
+ parseDefinition(" def foo(v: Int) at {}: Unit = <>" )
1020
+ parseDefinition(" def foo(v: Int) at io: Unit = <>" )
1021
+ parseDefinition(" def foo(v: Int) at {async, io}: Unit = <>" )
1022
+ }
1023
+
1016
1024
test(" Function definition" ){
1017
1025
val (source, pos) =
1018
1026
raw """ def foo[T1, T2](x: T1, y: T2){b: => Unit}: Unit = <>
@@ -1022,7 +1030,7 @@ class ParserTests extends munit.FunSuite {
1022
1030
val definition = parseDefinition(source.content)
1023
1031
1024
1032
val funDef = definition match {
1025
- case fd@ FunDef (id, tparams, vparams, bparams, ret, body, doc, span) => fd
1033
+ case fd@ FunDef (id, tparams, vparams, bparams, captures, ret, body, doc, span) => fd
1026
1034
case other =>
1027
1035
throw new IllegalArgumentException (s " Expected FunDef but got ${other.getClass.getSimpleName}" )
1028
1036
}
@@ -1041,7 +1049,7 @@ class ParserTests extends munit.FunSuite {
1041
1049
val definition = parseDefinition(source.content)
1042
1050
1043
1051
val funDef = definition match {
1044
- case fd@ FunDef (id, tparams, vparams, bparams, ret, body, doc, span) => fd
1052
+ case fd@ FunDef (id, tparams, vparams, bparams, captures, ret, body, doc, span) => fd
1045
1053
case other =>
1046
1054
throw new IllegalArgumentException (s " Expected FunDef but got ${other.getClass.getSimpleName}" )
1047
1055
}
@@ -1058,7 +1066,7 @@ class ParserTests extends munit.FunSuite {
1058
1066
val definition = parseDefinition(source.content)
1059
1067
1060
1068
val funDef = definition match {
1061
- case fd@ FunDef (id, tparams, vparams, bparams, ret, body, doc, span) => fd
1069
+ case fd@ FunDef (id, tparams, vparams, bparams, captures, ret, body, doc, span) => fd
1062
1070
case other =>
1063
1071
throw new IllegalArgumentException (s " Expected FunDef but got ${other.getClass.getSimpleName}" )
1064
1072
}
@@ -1086,7 +1094,7 @@ class ParserTests extends munit.FunSuite {
1086
1094
val definition = parseDefinition(source.content)
1087
1095
1088
1096
val funDef = definition match {
1089
- case fd@ FunDef (id, tparams, vparams, bparams, ret, body, doc, span) => fd
1097
+ case fd@ FunDef (id, tparams, vparams, bparams, captures, ret, body, doc, span) => fd
1090
1098
case other =>
1091
1099
throw new IllegalArgumentException (s " Expected FunDef but got ${other.getClass.getSimpleName}" )
1092
1100
}
@@ -1130,45 +1138,41 @@ class ParserTests extends munit.FunSuite {
1130
1138
assertEquals(valDef.span, span)
1131
1139
}
1132
1140
1133
- test(" Declaration info with capture set " ) {
1141
+ test(" Declaration info with comment and extern " ) {
1134
1142
val (source, pos) =
1135
1143
raw """ /// Some doc comment
1136
- |private extern {a, b, c}
1137
- |↑ ↑↑ ↑↑ ↑
1144
+ |private extern
1145
+ |↑ ↑↑ ↑
1138
1146
| """ .sourceAndPositions
1139
1147
1140
1148
parseInfo(source.content) match {
1141
1149
case Info (
1142
1150
Some (doc),
1143
1151
isPrivate,
1144
1152
isExtern,
1145
- Some ( CaptureSet (captures, Span (_, captFrom, captTo, _))) ) =>
1153
+ ) =>
1146
1154
1147
1155
assertEquals(doc, " Some doc comment" )
1148
1156
assertEquals(isPrivate, Maybe (Some (()), Span (source, pos(0 ), pos(1 ))))
1149
1157
assertEquals(isExtern, Maybe (Some (()), Span (source, pos(2 ), pos(3 ))))
1150
- assertEquals(captures.map(_.name), List (" a" , " b" , " c" ))
1151
- assertEquals(captFrom, pos(4 ))
1152
- assertEquals(captTo, pos(5 ))
1153
1158
1154
1159
case info => fail(s " Wrong info: ${info}" )
1155
1160
}
1156
1161
}
1157
1162
1158
- test(" Only private" ) {
1163
+ test(" Only comment and private" ) {
1159
1164
val (source, pos) =
1160
1165
raw """ /// Some doc comment
1161
1166
|private
1162
1167
|↑ ↑
1163
1168
| """ .sourceAndPositions
1164
1169
1165
1170
parseInfo(source.content) match {
1166
- case Info (doc, isPrivate, isExtern, externCapture ) =>
1171
+ case Info (doc, isPrivate, isExtern) =>
1167
1172
1168
1173
assertEquals(doc, Some (" Some doc comment" ))
1169
1174
assertEquals(isPrivate, Maybe (Some (()), Span (source, pos(0 ), pos(1 ))))
1170
1175
assertEquals(isExtern, Maybe (None , Span (source, pos(1 ), pos(1 ))))
1171
- assertEquals(externCapture, None )
1172
1176
}
1173
1177
}
1174
1178
@@ -1179,11 +1183,10 @@ class ParserTests extends munit.FunSuite {
1179
1183
| """ .sourceAndPositions
1180
1184
1181
1185
parseInfo(source.content) match {
1182
- case Info (doc, isPrivate, isExtern, externCapture ) =>
1186
+ case Info (doc, isPrivate, isExtern) =>
1183
1187
assertEquals(doc, Some (" Some doc comment" ))
1184
1188
assertEquals(isPrivate, Maybe (None , Span (source, pos(0 ), pos(0 ))))
1185
1189
assertEquals(isExtern, Maybe (None , Span (source, pos(0 ), pos(0 ))))
1186
- assertEquals(externCapture, None )
1187
1190
}
1188
1191
}
1189
1192
@@ -1587,7 +1590,7 @@ class ParserTests extends munit.FunSuite {
1587
1590
}
1588
1591
1589
1592
test(" Extern definition" ) {
1590
- parseExternDef(" extern {io} def read(s: String): Int = default { 42 } js { 1 + 1 } chez { 42 }" )
1593
+ parseExternDef(" extern def read(s: String) at {io} : Int = default { 42 } js { 1 + 1 } chez { 42 }" )
1591
1594
parseExternDef(" extern \" console.log(42)\" " )
1592
1595
parseExternDef(" extern \"\"\" console.log(42)\"\"\" " )
1593
1596
parseExternDef(" extern type Complex" )
@@ -1596,7 +1599,7 @@ class ParserTests extends munit.FunSuite {
1596
1599
parseExternDef(" extern resource withFile: [A](String) { () => A } => A" )
1597
1600
parseExternDef(" extern include \" path/to/file\" " )
1598
1601
parseExternDef(" extern js \"\"\" console.log(42)\"\"\" " )
1599
- parseExternDef(" extern pure def read(s: String): String = default { s }" )
1602
+ parseExternDef(" extern def read(s: String) at {} : String = default { s }" )
1600
1603
parseExternDef(" extern def read(s: String): String = \" ${s}\" " )
1601
1604
parseProgram(
1602
1605
" extern def println(value: String): Unit =" +
0 commit comments