mirror of
https://github.com/vlang/v.git
synced 2025-09-15 07:22:27 +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.
|
possible to return multiple values and still signal an error.
|
||||||
|
|
||||||
```v
|
```v
|
||||||
fn multireturn(v int) !(int, int) {
|
fn multi_return(v int) !(int, int) {
|
||||||
if v < 0 {
|
if v < 0 {
|
||||||
return error('must be positive')
|
return error('must be positive')
|
||||||
}
|
}
|
||||||
|
|
|
@ -1157,6 +1157,10 @@ fn (mut p Parser) stmt(is_top_level bool) ast.Stmt {
|
||||||
.semicolon {
|
.semicolon {
|
||||||
return p.semicolon_stmt()
|
return p.semicolon_stmt()
|
||||||
}
|
}
|
||||||
|
// Allow struct definitions inside functions
|
||||||
|
.key_struct, .key_union {
|
||||||
|
return p.struct_decl(false)
|
||||||
|
}
|
||||||
// literals, 'if', etc. in here
|
// literals, 'if', etc. in here
|
||||||
else {
|
else {
|
||||||
return p.parse_multi_expr(is_top_level)
|
return p.parse_multi_expr(is_top_level)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue