V: fails to compile anonymous function returning error in struct definition

Created on 30 Jun 2020  路  1Comment  路  Source: vlang/v

V version: V 0.1.28 a3086a2
OS: Arch Linux 5.7.6

What did you do?
Define an anonymous function that returns an error

pub struct Command {
        ...
    pre_execute fn(cmd Command)?
    execute fn(cmd Command)?
    post_execute fn(cmd Command)?
        ...
}

What did you expect to see?
It should compile, because it does compile when returning other things (e.g. ?bool) or when adding the (optional) comma at the end of line

What did you see instead?

vlib/cli/command.v:11:10: error: unexpected `fn`, expecting `name` 
    9 |     version string
   10 |     pre_execute fn(cmd Command)?
   11 |     execute fn(cmd Command)?
      |             ~~
   12 |     post_execute fn(cmd Command)?
   13 |
Bug

Most helpful comment

Unless anyone else is working on this. I will take a look at it.

>All comments

Unless anyone else is working on this. I will take a look at it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

shouji-kazuo picture shouji-kazuo  路  3Comments

markgraydev picture markgraydev  路  3Comments

oleg-kachan picture oleg-kachan  路  3Comments

radare picture radare  路  3Comments

medvednikov picture medvednikov  路  3Comments