V: error: incompatible type for argument 2 of ‘string_at’

Created on 3 Nov 2020  Â·  1Comment  Â·  Source: vlang/v


V version: latest git
OS: Arch Linux x64

What did you do?

v:='hello'
v[v.last_index('l')]

What did you expect to see?
no errors

What did you see instead?

/tmp/v/lastfail.6607056726981487751.tmp.c: In function ‘main__main’:
/tmp/v/lastfail.6607056726981487751.tmp.c:8005:15: error: incompatible type for argument 2 of ‘string_at’
 8005 |  string_at(v, string_last_index(v, tos_lit("l")));
      |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |               |
      |               Option_int
/tmp/v/lastfail.6607056726981487751.tmp.c:7497:37: note: expected ‘int’ but argument is of type ‘Option_int’
 7497 | static byte string_at(string s, int idx) {
      |                                 ~~~~^~~
...
==================
(Use `v -cg` to print the entire error message)

Bug

Most helpful comment

at least a V error should appear. string_last_index returns an Option

>All comments

at least a V error should appear. string_last_index returns an Option

Was this page helpful?
0 / 5 - 0 ratings

Related issues

clpo13 picture clpo13  Â·  3Comments

shouji-kazuo picture shouji-kazuo  Â·  3Comments

markgraydev picture markgraydev  Â·  3Comments

oleg-kachan picture oleg-kachan  Â·  3Comments

choleraehyq picture choleraehyq  Â·  3Comments