V: C error on calling a generics function without specifying the module

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


V version: 0.1.30 39b46e9
OS: Linux 5.8.0-29-generic

What did you do?

import os
arr := read_file_array<int>('input.txt')
 ```

**What did you expect to see?**
An error saying that the function is not defined

**What did you see instead?**

aoc1.v:1:8: warning: module 'os' is imported but never used
1 | import os
| ~~
2 | arr := read_file_array('input.txt')
aoc1.v:2:1: warning: unused variable: arr
1 | import os
2 | arr := read_file_array('input.txt')

| ~~~

/tmp/v/aoc1.5226188587236498710.tmp.c: In function ‘main__main’:
/tmp/v/aoc1.5226188587236498710.tmp.c:10759:18: error: implicit declaration of function ‘os__read_file_array_T_int’ [-Werror=implicit-function-declaration]
10759 | array_int arr = os__read_file_array_T_int(tos_lit("input.txt"));
| ^~~~~~~~~
/tmp/v/aoc1.5226188587236498710.tmp.c:10759:18: error: invalid initializer
cc1: some warnings being treated as errors

...

(Use v -cg to print the entire error message)

builder error:

C error. This should never happen.
```

Bug

Most helpful comment

This works because when pref.is_script is true you can call functions from the os module without the prefix but of course the error needs to be fixed

>All comments

This works because when pref.is_script is true you can call functions from the os module without the prefix but of course the error needs to be fixed

Was this page helpful?
0 / 5 - 0 ratings

Related issues

penguindark picture penguindark  Â·  3Comments

shouji-kazuo picture shouji-kazuo  Â·  3Comments

clpo13 picture clpo13  Â·  3Comments

jtkirkpatrick picture jtkirkpatrick  Â·  3Comments

markgraydev picture markgraydev  Â·  3Comments