Repository navigation
Commit d93f5cb
authored
Fix parsing of ReScript compiler syntax examples (#309)
ReScript compiler printer fixtures exposed missing grammar rules and premature automatic semicolon insertion. This PR allows those constructs to parse without `ERROR` or `MISSING` nodes and adds 28 regression tests organized by syntax category.
### Declaration continuations
Newlines and comments before `constraint` or a binding's `=` no longer terminate the declaration:
```rescript
type result<'good, 'bad> =
| Good('good)
| Bad('bad)
constraint 'good = bool
constraint 'bad = float
let identity: int => int
/* The initializer belongs to the same binding. */
= value => value
```
### Extensible types and constructor rebindings
Support private extensible types and constructor aliases, including qualified aliases and decorated constructors:
```rescript
module Private = {type t = private ..}
type event = ..
type event += Original(int)
type event += Alias = Original
```
### Functors
Support bare and anonymous functor parameters, unit parameters, and type annotations on functor arguments:
```rescript
module type Input = {type t}
module type Output = {type t}
module type Build = Input => Output
module type Anonymous = (_: Input) => Output
module Make = (Config: Input, ()) => {type t = Config.t}
module Config = {type t = int}
module Result = Make(Config: Input, ())
```
### Expression receivers and labeled arguments
Braced expressions can be used as call, member-access, and subscript receivers. Labeled arguments now accept punned type annotations and combined source-type/coercion annotations:
```rescript
let add = (a, b) => a + b
let sum = {add}(1, 2)
let values = [1, 2]
let first = {values}[{0}]
let call = (~value: int) => value
let value = 1
let typed = call(~value: int)
let coerced = call(~value=value : int :> int)
```
## Additional Coverage
- Polymorphic variant conjunctions (`&`) and escaped type variables.
- Repeated type constraints in module type refinements.
- Explicit exception result types and extensions in type/pattern positions.
- Type annotations in collection patterns and optional parenthesized record patterns.
- Adjacent decorators and decorator payloads containing patterns, guards, or declarations.
- Signature payloads in extensions.
- Regression cases for tuple callbacks, decorator statement boundaries, and continuations through comments.
The generated parser and node metadata are updated. The ReScript development dependency is updated to `13.0.0-alpha.7` for compiler validation.1 parent cc6a15e commit d93f5cb
15 files changed
Lines changed: 205617 additions & 172314 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
23 | 26 | | |
24 | 27 | | |
25 | 28 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
133 | 136 | | |
134 | 137 | | |
135 | 138 | | |
| |||
150 | 153 | | |
151 | 154 | | |
152 | 155 | | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
153 | 194 | | |
154 | 195 | | |
155 | 196 | | |
| |||
253 | 294 | | |
254 | 295 | | |
255 | 296 | | |
256 | | - | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
257 | 304 | | |
258 | 305 | | |
259 | 306 | | |
| |||
263 | 310 | | |
264 | 311 | | |
265 | 312 | | |
266 | | - | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
267 | 318 | | |
268 | 319 | | |
269 | | - | |
| 320 | + | |
270 | 321 | | |
271 | 322 | | |
272 | 323 | | |
| |||
276 | 327 | | |
277 | 328 | | |
278 | 329 | | |
| 330 | + | |
279 | 331 | | |
280 | 332 | | |
281 | 333 | | |
| |||
295 | 347 | | |
296 | 348 | | |
297 | 349 | | |
298 | | - | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
299 | 356 | | |
300 | 357 | | |
301 | 358 | | |
| |||
339 | 396 | | |
340 | 397 | | |
341 | 398 | | |
| 399 | + | |
342 | 400 | | |
343 | 401 | | |
344 | 402 | | |
| |||
366 | 424 | | |
367 | 425 | | |
368 | 426 | | |
369 | | - | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
370 | 436 | | |
371 | 437 | | |
372 | 438 | | |
| |||
387 | 453 | | |
388 | 454 | | |
389 | 455 | | |
390 | | - | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
391 | 461 | | |
392 | 462 | | |
393 | 463 | | |
| |||
676 | 746 | | |
677 | 747 | | |
678 | 748 | | |
679 | | - | |
| 749 | + | |
680 | 750 | | |
681 | 751 | | |
682 | 752 | | |
| |||
720 | 790 | | |
721 | 791 | | |
722 | 792 | | |
| 793 | + | |
723 | 794 | | |
724 | 795 | | |
725 | 796 | | |
| |||
792 | 863 | | |
793 | 864 | | |
794 | 865 | | |
| 866 | + | |
795 | 867 | | |
796 | 868 | | |
797 | 869 | | |
798 | 870 | | |
799 | 871 | | |
| 872 | + | |
800 | 873 | | |
801 | 874 | | |
802 | 875 | | |
| |||
896 | 969 | | |
897 | 970 | | |
898 | 971 | | |
899 | | - | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
900 | 977 | | |
901 | 978 | | |
902 | 979 | | |
| |||
1004 | 1081 | | |
1005 | 1082 | | |
1006 | 1083 | | |
1007 | | - | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
1008 | 1094 | | |
1009 | 1095 | | |
1010 | 1096 | | |
1011 | 1097 | | |
1012 | 1098 | | |
1013 | | - | |
| 1099 | + | |
1014 | 1100 | | |
1015 | 1101 | | |
1016 | 1102 | | |
| |||
1021 | 1107 | | |
1022 | 1108 | | |
1023 | 1109 | | |
1024 | | - | |
| 1110 | + | |
1025 | 1111 | | |
1026 | 1112 | | |
1027 | 1113 | | |
| |||
1107 | 1193 | | |
1108 | 1194 | | |
1109 | 1195 | | |
1110 | | - | |
1111 | | - | |
1112 | | - | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
1113 | 1199 | | |
1114 | 1200 | | |
1115 | 1201 | | |
1116 | 1202 | | |
1117 | 1203 | | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
1118 | 1222 | | |
1119 | | - | |
1120 | 1223 | | |
1121 | 1224 | | |
1122 | 1225 | | |
1123 | 1226 | | |
1124 | | - | |
1125 | 1227 | | |
1126 | 1228 | | |
1127 | 1229 | | |
| |||
1153 | 1255 | | |
1154 | 1256 | | |
1155 | 1257 | | |
1156 | | - | |
| 1258 | + | |
| 1259 | + | |
| 1260 | + | |
| 1261 | + | |
| 1262 | + | |
| 1263 | + | |
| 1264 | + | |
| 1265 | + | |
| 1266 | + | |
| 1267 | + | |
| 1268 | + | |
| 1269 | + | |
| 1270 | + | |
| 1271 | + | |
1157 | 1272 | | |
1158 | 1273 | | |
1159 | 1274 | | |
| |||
1243 | 1358 | | |
1244 | 1359 | | |
1245 | 1360 | | |
1246 | | - | |
| 1361 | + | |
| 1362 | + | |
| 1363 | + | |
| 1364 | + | |
| 1365 | + | |
| 1366 | + | |
| 1367 | + | |
| 1368 | + | |
1247 | 1369 | | |
1248 | 1370 | | |
1249 | 1371 | | |
1250 | 1372 | | |
1251 | 1373 | | |
1252 | 1374 | | |
1253 | 1375 | | |
1254 | | - | |
| 1376 | + | |
| 1377 | + | |
| 1378 | + | |
| 1379 | + | |
| 1380 | + | |
| 1381 | + | |
1255 | 1382 | | |
1256 | 1383 | | |
1257 | 1384 | | |
| |||
1265 | 1392 | | |
1266 | 1393 | | |
1267 | 1394 | | |
1268 | | - | |
| 1395 | + | |
| 1396 | + | |
| 1397 | + | |
| 1398 | + | |
| 1399 | + | |
| 1400 | + | |
1269 | 1401 | | |
1270 | 1402 | | |
1271 | 1403 | | |
| |||
1434 | 1566 | | |
1435 | 1567 | | |
1436 | 1568 | | |
1437 | | - | |
1438 | | - | |
| 1569 | + | |
| 1570 | + | |
| 1571 | + | |
| 1572 | + | |
| 1573 | + | |
1439 | 1574 | | |
1440 | 1575 | | |
1441 | 1576 | | |
| |||
0 commit comments