v icon indicating copy to clipboard operation
v copied to clipboard

Use of `multi return` types in Generics leads to C error

Open Apocryphon-X opened this issue 2 years ago • 0 comments

V Doctor:

OS: linux, Ubuntu 20.04.4 LTS (WSL 2)
Processor: 12 cpus, 64bit, little endian, 11th Gen Intel(R) Core(TM) i5-11400H @ 2.70GHz
CC version: cc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0

getwd: /home/apocryphon/tests/v
vmodules: /home/apocryphon/.vmodules
vroot: /home/apocryphon/packages/v
vexe: /home/apocryphon/packages/v/v
vexe mtime: 2022-08-06 16:46:27
is vroot writable: true
is vmodules writable: true
V full version: V 0.3.0 d6de533.d6b594c

Git version: git version 2.25.1
Git vroot status: weekly.2022.31-22-gd6b594c4
.git/config present: true
thirdparty/tcc status: thirdparty-linux-amd64 827f7452

What did you do?

struct Tuple<T> {
    data T
}

fn main() {
    sample := Tuple<(int, int)>{}
    println(sample)
}

What did you expect to see?

There is a related discussion about this in #15300. To make it short, the code above (with some additions) should result in a compilation error or a successful program with behavior resembling tuples (like the ones in Python).

Related to:

  • #15359
  • #15083
  • #15366
  • #15300

What did you see instead?

v -cg:

/tmp/v_1000/m2.12566730850537185187.tmp.c:1074: error: field 'data' has incomplete type
builder error:
==================
C error. This should never happen.

This is a compiler bug, please report it using `v bug file.v`.

https://github.com/vlang/v/issues/new/choose

You can also use #help on Discord: https://discord.gg/vlang

v -cg -prod:

/tmp/v_1000/m2.16452454173144520647.tmp.c:1075:23: error: field ‘data’ has incomplete type
 1075 |  multi_return_int_int data;
      |                       ^~~~
builder error:
==================
C error. This should never happen.

This is a compiler bug, please report it using `v bug file.v`.

https://github.com/vlang/v/issues/new/choose

You can also use #help on Discord: https://discord.gg/vlang

Apocryphon-X avatar Aug 06 '22 19:08 Apocryphon-X