Skip to content

generic compilation error #25125

Description

@get200
V version: V 0.4.11 4f8a3da, press to see full `v doctor` output
V full version V 0.4.11 747af8c.4f8a3da
OS windows, Microsoft Windows 11 专业版 Insider Preview 26200 64-bit
Processor 24 cpus, 64bit, little endian, AMD Ryzen 9 5900X 12-Core Processor
Memory 50.11GB/63.91GB
V executable D:\v\v\v.exe
V last modified time 2025-08-17 07:21:49
V home dir OK, value: D:\v\v
VMODULES OK, value: C:\Users\Administrator.vmodules
VTMP OK, value: C:\Users\Administrator\AppData\Local\Temp\v_0
Current working dir OK, value: E:\2025\v\v_test
Git version git version 2.46.0.windows.1
V git status weekly.2022.48-5905-g4f8a3daf-dirty
.git/config present true
cc version cc (Rev5, Built by MSYS2 project) 13.2.0
gcc version gcc (Rev5, Built by MSYS2 project) 13.2.0
clang version clang version 18.1.6
msvc version N/A
tcc version tcc version 0.9.27 (x86_64 Windows)
tcc git status thirdparty-windows-amd64 b425ac82
emcc version N/A
glibc version N/A

What did you do?
./v -g -o vdbg cmd/v && ./vdbg gen3.v && E:\2025\v\v_test\gen3.exe

module main

struct AnyStruct[T] {
	val T
}

fn decode_struct[T]() T {
	mut typ := T{}
	$for field in T.fields {
		typ.$(field.name) = decode_field(typ.$(field.name))
	}
	return typ
}

fn decode_field[T](_ T) T {
	mut field := T{}
	return field
}

type Any = int | string | []Any

fn main() {
	decode_struct[AnyStruct[Any]]()
	decode_struct[AnyStruct[[]Any]]()
}

What did you see?

================== C compilation error (from tcc): ==============
cc: d:/v/v/thirdparty/tcc/include/winapi/synchapi.h:167: warning: CreateMutex redefined
cc: C:/Users/Administrator/AppData/Local/Temp/v_0/gen3.01K2VEMZPDRG4YCJRCRAX0AK9J.tmp.c:5269: error: cannot convert 'struct main__Any' to 'void *'
...
cc: C:/Users/Administrator/AppData/Local/Temp/v_0/gen3.01K2VEMZPDRG4YCJRCRAX0AK9J.tmp.c:5269: error: cannot convert 'struct main__Any' to 'void *'
(note: the original output was 8 lines long; it was truncated to its first 2 lines + the last line)
=================================================================
(You can pass `-cg`, or `-show-c-output` as well, to print all the C error messages).
builder error: 
==================
C error found. It should never happen, when compiling pure V code.
This is a V compiler bug, please report it using `v bug file.v`,
or goto https://github.com/vlang/v/issues/new/choose .
You can also use #help on Discord: https://discord.gg/vlang .

What did you expect to see?

complied success

Note

You can use the 👍 reaction to increase the issue's priority for developers.

Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.

Metadata

Metadata

Assignees

Labels

BugThis tag is applied to issues which reports bugs.ComptimeFeatures processed during compile time, like $if, $for, $env etc

Type

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions