Skip to content

Commit 57a1b73

Browse files
committed
Update internal syntax.md
1 parent 169dd69 commit 57a1b73

File tree

1 file changed

+27
-6
lines changed

1 file changed

+27
-6
lines changed

docs/_docs/internals/syntax.md

+27-6
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ type val var while with yield
141141
### Soft keywords
142142

143143
```
144-
as derives end erased extension infix inline opaque open throws tracked transparent using | * + -
144+
as derives end erased extension infix inline mut opaque open throws tracked transparent using | * + -
145145
```
146146

147147
See the [separate section on soft keywords](../reference/soft-modifier.md) for additional
@@ -182,15 +182,19 @@ Type ::= FunType
182182
| MatchType
183183
| InfixType
184184
FunType ::= FunTypeArgs (‘=>’ | ‘?=>’) Type Function(ts, t) | FunctionWithMods(ts, t, mods, erasedParams)
185-
| TypTypeParamClause '=>' Type PolyFunction(ps, t)
185+
| FunTypeArgs (‘->’ | ‘?->’) [CaptureSet] Type -- under pureFunctions and captureChecking
186+
| TypTypeParamClause ‘=>’ Type PolyFunction(ps, t)
187+
| TypTypeParamClause ‘->’ [CaptureSet] Type -- under pureFunctions and captureChecking
186188
FunTypeArgs ::= InfixType
187189
| ‘(’ [ FunArgTypes ] ‘)’
188190
| FunParamClause
189191
FunParamClause ::= ‘(’ TypedFunParam {‘,’ TypedFunParam } ‘)’
190192
TypedFunParam ::= [`erased`] id ‘:’ Type
191193
MatchType ::= InfixType `match` <<< TypeCaseClauses >>>
192194
InfixType ::= RefinedType {id [nl] RefinedType} InfixOp(t1, op, t2)
195+
| RefinedType ‘^’ -- under captureChecking
193196
RefinedType ::= AnnotType {[nl] Refinement} RefinedTypeTree(t, ds)
197+
| AnnotType {[nl] Refinement} ‘^’ CaptureSet -- under captureChecking
194198
AnnotType ::= SimpleType {Annotation} Annotated(t, annot)
195199
AnnotType1 ::= SimpleType1 {Annotation} Annotated(t, annot)
196200
@@ -210,26 +214,35 @@ Singleton ::= SimpleRef
210214
| Singleton ‘.’ id
211215
FunArgType ::= Type
212216
| ‘=>’ Type PrefixOp(=>, t)
217+
| ‘->’ [CaptureSet] Type -- under captureChecking
213218
FunArgTypes ::= FunArgType { ‘,’ FunArgType }
214219
ParamType ::= [‘=>’] ParamValueType
220+
| ‘->’ [CaptureSet] ParamValueType -- under captureChecking
215221
ParamValueType ::= Type [‘*’] PostfixOp(t, "*")
216222
| IntoType
217223
| ‘(’ IntoType ‘)’ ‘*’ PostfixOp(t, "*")
218224
IntoType ::= [‘into’] IntoTargetType Into(t)
219225
| ‘(’ IntoType ‘)’
220226
IntoTargetType ::= Type
221227
| FunTypeArgs (‘=>’ | ‘?=>’) IntoType
222-
TypeArgs ::= ‘[’ Types ‘]’ ts
228+
TypeArgs ::= ‘[’ TypeArg {‘,’ TypeArg} ‘]’ ts
223229
Refinement ::= :<<< [RefineDcl] {semi [RefineDcl]} >>> ds
224-
TypeBounds ::= [‘>:’ Type] [‘<:’ Type] TypeBoundsTree(lo, hi)
230+
TypeBounds ::= [‘>:’ TypeBound] [‘<:’ TypeBound] TypeBoundsTree(lo, hi)
225231
TypeAndCtxBounds ::= TypeBounds [‘:’ ContextBounds] ContextBounds(typeBounds, tps)
226232
ContextBounds ::= ContextBound
227233
| ContextBound `:` ContextBounds -- to be deprecated
228234
| '{' ContextBound {',' ContextBound} '}'
229235
ContextBound ::= Type ['as' id]
230236
Types ::= Type {‘,’ Type}
237+
TypeArg ::= Type
238+
| CaptureSet -- under captureChecking
239+
TypeBound ::= Type
240+
| CaptureSet -- under captureChecking
231241
NamesAndTypes ::= NameAndType {‘,’ NameAndType}
232242
NameAndType ::= id ':' Type
243+
CaptureSet ::= ‘{’ CaptureRef {‘,’ CaptureRef} ‘}’ -- under captureChecking
244+
CaptureRef ::= { SimpleRef ‘.’ } SimpleRef [‘*’] [‘.’ ‘rd’] -- under captureChecking
245+
| [ { SimpleRef ‘.’ } SimpleRef ‘.’ ] id -- under captureChecking
233246
```
234247

235248
### Expressions
@@ -365,16 +378,20 @@ ArgumentPatterns ::= ‘(’ [Patterns] ‘)’
365378
ClsTypeParamClause::= ‘[’ ClsTypeParam {‘,’ ClsTypeParam} ‘]’
366379
ClsTypeParam ::= {Annotation} [‘+’ | ‘-’] TypeDef(Modifiers, name, tparams, bounds)
367380
id [HkTypeParamClause] TypeAndCtxBounds Bound(below, above, context)
381+
| {Annotation} id [`^`] TypeAndCtxBounds -- under captureChecking
368382
369383
DefTypeParamClause::= [nl] ‘[’ DefTypeParam {‘,’ DefTypeParam} ‘]’
370384
DefTypeParam ::= {Annotation} id [HkTypeParamClause] TypeAndCtxBounds
385+
| {Annotation} id [`^`] TypeAndCtxBounds -- under captureChecking
371386
372387
TypTypeParamClause::= ‘[’ TypTypeParam {‘,’ TypTypeParam} ‘]’
373-
TypTypeParam ::= {Annotation} (id | ‘_’) [HkTypeParamClause] TypeBounds
388+
TypTypeParam ::= {Annotation} (id | ‘_’) [HkTypeParamClause] TypeAndCtxBounds
389+
| {Annotation} id [`^`] TypeAndCtxBounds -- under captureChecking
374390
375391
HkTypeParamClause ::= ‘[’ HkTypeParam {‘,’ HkTypeParam} ‘]’
376392
HkTypeParam ::= {Annotation} [‘+’ | ‘-’] (id | ‘_’) [HkTypeParamClause]
377393
TypeBounds
394+
| {Annotation} id [`^`] TypeBounds -- under captureChecking
378395
379396
ClsParamClauses ::= {ClsParamClause} [[nl] ‘(’ [‘implicit’] ClsParams ‘)’]
380397
ClsParamClause ::= [nl] ‘(’ ClsParams ‘)’
@@ -419,6 +436,7 @@ LocalModifier ::= ‘abstract’
419436
| ‘infix’
420437
| ‘erased’
421438
| ‘tracked’
439+
| ‘mut’ -- under captureChecking
422440
423441
AccessModifier ::= (‘private’ | ‘protected’) [AccessQualifier]
424442
AccessQualifier ::= ‘[’ id ‘]’
@@ -462,7 +480,10 @@ DefDef ::= DefSig [‘:’ Type] [‘=’ Expr]
462480
| ‘this’ ConstrParamClauses [DefImplicitClause] ‘=’ ConstrExpr DefDef(_, <init>, vparamss, EmptyTree, expr | Block)
463481
DefSig ::= id [DefParamClauses] [DefImplicitClause]
464482
TypeDef ::= id [HkTypeParamClause] {FunParamClause} TypeAndCtxBounds TypeDefTree(_, name, tparams, bound
465-
[‘=’ Type]
483+
[‘=’ TypeDefRHS]
484+
| id [`^`] TypeAndCtxBounds [‘=’ TypeDefRHS] -- under captureChecking
485+
TypeDefRHS ::= Type
486+
| CaptureSet -- under captureChecking
466487
467488
TmplDef ::= ([‘case’] ‘class’ | ‘trait’) ClassDef
468489
| [‘case’] ‘object’ ObjectDef

0 commit comments

Comments
 (0)