V: Enum array as struct field fails

Created on 25 May 2020  路  2Comments  路  Source: vlang/v

V version: V 0.1.27 f8b2374
OS: 5.4.40-1-MANJARO

What did you do?
Add a test for enum array as struct fields:

struct Abc {
mut:
    flags []Flag
}

enum Flag {
    flag_one
    flag_two
}

fn test_enum_array_field() {
    mut a := Abc{}
    a.flags << .flag_one
}

Then run v test vlib/v/test/enum_array_field_test.v

What did you expect to see?
Test passing

What did you see instead?

$ v test vlib/v/tests/enum_array_field_test.v
----------------------------------------------------------------------- Testing... ---------------------------------------------------------------------
FAIL   37.446 ms vlib/v/tests/enum_array_field_test.v
vlib/v/tests/enum_array_field_test.v:14:1: error: not an enum 
   12 |     mut a := Abc{}
   13 |     a.flags << .flag_one
   14 | }
      | ^

--------------------------------------------------------------------------------------------------------------------------------------------------------
       38.368 ms <=== total time spent running V _test.v files
                 ok, fail, skip, total =     0,     1,     0,     1

Notes
This prevents the net.websocket module from compiling.

Bug

Most helpful comment

it now works with just .flag_one too in 5825e46

All 2 comments

As a workaround, use
a.flags << Flag.flag_one

it now works with just .flag_one too in 5825e46

Was this page helpful?
0 / 5 - 0 ratings

Related issues

clpo13 picture clpo13  路  3Comments

medvednikov picture medvednikov  路  3Comments

aurora picture aurora  路  3Comments

XVilka picture XVilka  路  3Comments

oleg-kachan picture oleg-kachan  路  3Comments