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

oleg-kachan picture oleg-kachan  路  3Comments

choleraehyq picture choleraehyq  路  3Comments

vtereshkov picture vtereshkov  路  3Comments

aurora picture aurora  路  3Comments

jtkirkpatrick picture jtkirkpatrick  路  3Comments