Skip to content

Commit e0850c6

Browse files
[create-pull-request] automated change (#1234)
Co-authored-by: jskeet <[email protected]>
1 parent a1a0195 commit e0850c6

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

standard/expressions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3305,7 +3305,7 @@ When a *stackalloc_initializer* is present:
33053305

33063306
Each *stackalloc_element_initializer* shall have an implicit conversion to *unmanaged_type* ([§10.2](conversions.md#102-implicit-conversions)). The *stackalloc_element_initializer*s initialize elements in the allocated memory in increasing order, starting with the element at index zero. In the absence of a *stackalloc_initializer*, the content of the newly allocated memory is undefined.
33073307

3308-
If a *stackalloc_expression* occurs directly as the initializing expression of a *local_variable_declaration* ([§13.6.2](statements.md#1362-local-variable-declarations)), where the *local_variable_type* is either a pointer type ([§23.3](unsafe-code.md#233-pointer-types)) or inferred (`var`), then the result of the *stackalloc_expression* is a pointer of type `T*` (§23.9). In this case the *stackalloc_expression* must appear in unsafe code. Otherwise the result of a *stackalloc_expression* is an instance of type `Span<T>`, where `T` is the *unmanaged_type*:
3308+
If a *stackalloc_expression* occurs directly as the initializing expression of a *local_variable_declaration* ([§13.6.2](statements.md#1362-local-variable-declarations)), where the *local_variable_type* is either a pointer type ([§23.3](unsafe-code.md#233-pointer-types)) or inferred (`var`), then the result of the *stackalloc_expression* is a pointer of type `T*` ([§23.9](unsafe-code.md#239-stack-allocation)). In this case the *stackalloc_expression* must appear in unsafe code. Otherwise the result of a *stackalloc_expression* is an instance of type `Span<T>`, where `T` is the *unmanaged_type*:
33093309

33103310
- `Span<T>` ([§C.3](standard-library.md#c3-standard-library-types-not-defined-in-isoiec-23271)) is a ref struct type ([§16.2.3](structs.md#1623-ref-modifier)), which presents a block of memory, here the block allocated by the *stackalloc_expression*, as an indexable collection of typed (`T`) items.
33113311
- The result’s `Length` property returns the number of items allocated.

standard/grammar.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -525,12 +525,12 @@ fragment PP_Line_Indicator
525525
;
526526
527527
fragment PP_Compilation_Unit_Name
528-
: '"' PP_Compilation_Unit_Name_Character+ '"'
528+
: '"' PP_Compilation_Unit_Name_Character* '"'
529529
;
530530
531531
fragment PP_Compilation_Unit_Name_Character
532532
// Any Input_Character except "
533-
: ~('\u000D' | '\u000A' | '\u0085' | '\u2028' | '\u2029' | '#')
533+
: ~('\u000D' | '\u000A' | '\u0085' | '\u2028' | '\u2029' | '"')
534534
;
535535
536536
// Source: §6.5.9 Nullable directive
@@ -1184,8 +1184,7 @@ default_literal
11841184
// Source: §12.8.22 Stack allocation
11851185
stackalloc_expression
11861186
: 'stackalloc' unmanaged_type '[' expression ']'
1187-
| 'stackalloc' unmanaged_type? '[' constant_expression? ']'
1188-
stackalloc_initializer
1187+
| 'stackalloc' unmanaged_type? '[' constant_expression? ']' stackalloc_initializer
11891188
;
11901189
11911190
stackalloc_initializer

0 commit comments

Comments
 (0)