v icon indicating copy to clipboard operation
v copied to clipboard

Compiler bug, implicit declaration of function

Open eptx opened this issue 2 years ago • 5 comments

V version: V 0.3.1 f7f0e0b OS: MacOS 12.6

What did you do? Tried to fix the following error...

error: generic struct cannot be used in non-generic function
  109 | 
  110 | fn test_double_sum() {
  111 |   mut data := [][]T{}
      |               ~~~~~~

By adding a generic type to the function (a test function)...

fn test_double_sum<T>() {
  mut data := [][]T{}
  data = [
    [0,0,0],
...
    [5.0,10.0,15.0]]

What did you expect to see? Test compiled and running. Just started with V so not clear how to define [][]T.

What did you see instead?

tmp.c:23707:3: error: implicit 
declaration of function 'main__test_double_sum' is inv
alid in C99 [-Werror,-Wimplicit-function-declaration]
                main__test_double_sum();
                ^
6 warnings and 1 error generated.
...
==================
(Use `v -cg` to print the entire error message)

builder error: 
==================
C error. This should never happen.

eptx avatar Oct 18 '22 22:10 eptx