mirror of
https://github.com/vlang/v.git
synced 2025-09-13 14:32:26 +03:00
parser: allow struct definitions inside functions
This commit is contained in:
parent
4f9df0da72
commit
a2d385aee3
2 changed files with 6 additions and 2 deletions
|
@ -4067,7 +4067,7 @@ Only one `Option` or `Result` is allowed to be returned from a function. It is
|
|||
possible to return multiple values and still signal an error.
|
||||
|
||||
```v
|
||||
fn multireturn(v int) !(int, int) {
|
||||
fn multi_return(v int) !(int, int) {
|
||||
if v < 0 {
|
||||
return error('must be positive')
|
||||
}
|
||||
|
@ -8065,4 +8065,4 @@ Assignment Operators
|
|||
&= |= ^=
|
||||
>>= <<= >>>=
|
||||
&&= ||=
|
||||
```
|
||||
```
|
||||
|
|
|
@ -1157,6 +1157,10 @@ fn (mut p Parser) stmt(is_top_level bool) ast.Stmt {
|
|||
.semicolon {
|
||||
return p.semicolon_stmt()
|
||||
}
|
||||
// Allow struct definitions inside functions
|
||||
.key_struct, .key_union {
|
||||
return p.struct_decl(false)
|
||||
}
|
||||
// literals, 'if', etc. in here
|
||||
else {
|
||||
return p.parse_multi_expr(is_top_level)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue