Skip to content

Commit 4b64b5d

Browse files
BillWagnerjskeet
authored andcommitted
allow unsafe and ref in grammar
`unsafe` and ref returns are allowed for delegates, local functions, and methods. Update the grammar for that part. Fixes #886 See #941 (review)
1 parent 16a5c62 commit 4b64b5d

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

standard/classes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1930,7 +1930,6 @@ method_header
19301930
method_modifier
19311931
: ref_method_modifier
19321932
| 'async'
1933-
| unsafe_modifier // unsafe code support
19341933
;
19351934
19361935
ref_method_modifier
@@ -1945,6 +1944,7 @@ ref_method_modifier
19451944
| 'override'
19461945
| 'abstract'
19471946
| 'extern'
1947+
| unsafe_modifier // unsafe code support
19481948
;
19491949
19501950
return_type

standard/delegates.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ A *delegate_declaration* is a *type_declaration* ([§14.7](namespaces.md#147-typ
1313
```ANTLR
1414
delegate_declaration
1515
: attributes? delegate_modifier* 'delegate' return_type delegate_header
16-
| attributes? ref_delegate_modifier* 'delegate' ref_kind ref_return_type delegate_header
16+
| attributes? delegate_modifier* 'delegate' ref_kind ref_return_type delegate_header
1717
;
1818
1919
delegate_header
@@ -22,16 +22,12 @@ delegate_header
2222
;
2323
2424
delegate_modifier
25-
: ref_delegate_modifier
26-
| unsafe_modifier // unsafe code support
27-
;
28-
29-
ref_delegate_modifier
3025
: 'new'
3126
| 'public'
3227
| 'protected'
3328
| 'internal'
3429
| 'private'
30+
| unsafe_modifier // unsafe code support
3531
;
3632
```
3733

standard/statements.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ A *local_function_declaration* declares a local function.
447447
```ANTLR
448448
local_function_declaration
449449
: local_function_modifier* return_type local_function_header local_function_body
450-
| ref_kind ref_return_type local_function_header ref_local_function_body
450+
| ref_local_function_modifier* ref_kind ref_return_type local_function_header ref_local_function_body
451451
;
452452
453453
local_function_header
@@ -456,8 +456,12 @@ local_function_header
456456
;
457457
458458
local_function_modifier
459-
: 'async'
460-
| unsafe_modifier // unsafe code support
459+
: ref_local_function_modifier
460+
| 'async'
461+
;
462+
463+
ref_local_function_modifier
464+
: unsafe_modifier // unsafe code support
461465
;
462466
463467
local_function_body

0 commit comments

Comments
 (0)