Skip to content

allow unsafe and ref in grammar #943

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 1 addition & 1 deletion standard/unsafe-code.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ An expression with a pointer type cannot be used to provide the value in a *memb

The default value ([§9.3](variables.md#93-default-values)) for any pointer type is `null`.

> *Note*: Although pointers can be passed as `ref` or `out` parameters, doing so can cause undefined behavior, since the pointer might well be set to point to a local variable that no longer exists when the called method returns, or the fixed object to which it used to point, is no longer fixed. For example:
> *Note*: Although pointers can be passed as `in`, `ref` or `out` parameters, doing so can cause undefined behavior, since the pointer might well be set to point to a local variable that no longer exists when the called method returns, or the fixed object to which it used to point, is no longer fixed. For example:
>
> <!-- Example: {template:"standalone-console-without-using", name:"PointerTypes1", replaceEllipsis:true} -->
> <!-- Note: the behavior of this example is undefined. -->
Expand Down