V: error: aggregate value used where an integer was expected

Created on 15 Dec 2020  Â·  1Comment  Â·  Source: vlang/v


V version: latest git
OS: Arch Linux x64

What did you do?
println(int('hi'.last_index('i')))

What did you expect to see?

What did you see instead?

v run hi.v
Compilation with tcc failed. Retrying with cc ...
==================
/tmp/v/hi.7872512775485591804.tmp.c: In function ‘main__main’:
/tmp/v/hi.7872512775485591804.tmp.c:8252:2: error: aggregate value used where an integer was expected
 8252 |  println(int_str(((int)(string_last_index(_SLIT("hi"), _SLIT("i"))))));
      |  ^~~~~~~
Bug

Most helpful comment

pub fn (s string) last_index(p string) ?int

So there's something wrong with this usage.

    a := 'hi'.last_index('i') or {-1}
    println(int(a))

But it needs to prompt for syntax errors.

>All comments

pub fn (s string) last_index(p string) ?int

So there's something wrong with this usage.

    a := 'hi'.last_index('i') or {-1}
    println(int(a))

But it needs to prompt for syntax errors.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ArcDrake picture ArcDrake  Â·  3Comments

aurora picture aurora  Â·  3Comments

penguindark picture penguindark  Â·  3Comments

markgraydev picture markgraydev  Â·  3Comments

radare picture radare  Â·  3Comments