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"))))));
| ^~~~~~~
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.
Most helpful comment
So there's something wrong with this usage.
But it needs to prompt for syntax errors.