Skip to content

Commit

Permalink
allow unsafe and ref in grammar
Browse files Browse the repository at this point in the history
`unsafe` and ref returns are allowed for delegates, local functions, and methods. Update the grammar for that part.

Fixes dotnet#886

See dotnet#941 (review)
  • Loading branch information
BillWagner committed Sep 20, 2023
1 parent 1d44af8 commit a5d37a8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion standard/classes.md
Original file line number Diff line number Diff line change
Expand Up @@ -1930,7 +1930,6 @@ method_header
method_modifier
: ref_method_modifier
| 'async'
| unsafe_modifier // unsafe code support
;
ref_method_modifier
Expand All @@ -1945,6 +1944,7 @@ ref_method_modifier
| 'override'
| 'abstract'
| 'extern'
| unsafe_modifier // unsafe code support
;
return_type
Expand Down
8 changes: 2 additions & 6 deletions standard/delegates.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ A *delegate_declaration* is a *type_declaration* ([§14.7](namespaces.md#147-typ
```ANTLR
delegate_declaration
: attributes? delegate_modifier* 'delegate' return_type delegate_header
| attributes? ref_delegate_modifier* 'delegate' ref_kind ref_return_type delegate_header
| attributes? delegate_modifier* 'delegate' ref_kind ref_return_type delegate_header
;
delegate_header
Expand All @@ -22,16 +22,12 @@ delegate_header
;
delegate_modifier
: ref_delegate_modifier
| unsafe_modifier // unsafe code support
;
ref_delegate_modifier
: 'new'
| 'public'
| 'protected'
| 'internal'
| 'private'
| unsafe_modifier // unsafe code support
;
```

Expand Down
10 changes: 7 additions & 3 deletions standard/statements.md
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ A *local_function_declaration* declares a local function.
```ANTLR
local_function_declaration
: local_function_modifier* return_type local_function_header local_function_body
| ref_kind ref_return_type local_function_header ref_local_function_body
| ref_local_function_modifier* ref_kind ref_return_type local_function_header ref_local_function_body
;
local_function_header
Expand All @@ -456,8 +456,12 @@ local_function_header
;
local_function_modifier
: 'async'
| unsafe_modifier // unsafe code support
: ref_local_function_modifier
| 'async'
;
ref_local_function_modifier
: unsafe_modifier // unsafe code support
;
local_function_body
Expand Down

0 comments on commit a5d37a8

Please sign in to comment.