Skip to content

Nested generics compilation error #24530

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
get200 opened this issue May 20, 2025 · 1 comment · May be fixed by #24565
Open

Nested generics compilation error #24530

get200 opened this issue May 20, 2025 · 1 comment · May be fixed by #24565
Assignees
Labels
Bug This tag is applied to issues which reports bugs. Generics[T] Bugs/feature requests, that are related to the V generics. Unit: cgen Bugs/feature requests, that are related to the default C generating backend.

Comments

@get200
Copy link
Contributor

get200 commented May 20, 2025

V version: V 0.4.10 2c42574, press to see full `v doctor` output
V full version V 0.4.10 2c42574
OS windows, Microsoft Windows 11 专业版 26100 64-bit
Processor 24 cpus, 64bit, little endian, AMD Ryzen 9 5900X 12-Core Processor
Memory 49.28GB/63.91GB
V executable D:\v\v\v.exe
V last modified time 2025-05-18 14:17:11
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-5439-g2c42574e-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 nested_gen.v && E:\2025\v\v_test\nested_gen.exe

module main

struct People[T] {
	raw T
}

struct Man {
	name string
}

fn main() {
	// p1 := People{Man{
	// 	name: 'Mike'
	// }}
	m1 := Man{
		name: 'Tom'
	}

	gen1(m1)
}

fn gen1[T](m T) {
	gen2[People[T]]()
}

fn gen2[T]() {
}

What did you see?

================== C compilation error (from tcc): ==============
cc: C:/Users/Administrator/AppData/Local/Temp/v_0/nested_gen.tmp.c:535: warning: WINVER redefined
cc: C:/Users/Administrator/AppData/Local/Temp/v_0/nested_gen.tmp.c:1436: error: constant expression expected
=================================================================
(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 .
1434 VV_LOCAL_SYMBOL void main__main(void);
1435 VV_LOCAL_SYMBOL void main__gen1_T_main__Man(main__Man m);
1436 VV_LOCAL_SYMBOL void main__gen2_T_main__People[main__Man](void);

What did you expect to see?
Compiled successfully

Compiles successfully if the following section is commented out.

module main

struct People[T] {
	raw T
}

struct Man {
	name string
}

fn main() {
	p1 := People{Man{
	 	name: 'Mike'
	 }}
	m1 := Man{
		name: 'Tom'
	}

	gen1(m1)
}

fn gen1[T](m T) {
	gen2[People[T]]()
}

fn gen2[T]() {
}

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.

Copy link

Connected to Huly®: V_0.6-22898

@felipensp felipensp added Bug This tag is applied to issues which reports bugs. Generics[T] Bugs/feature requests, that are related to the V generics. labels May 24, 2025
@felipensp felipensp self-assigned this May 24, 2025
@felipensp felipensp added the Unit: cgen Bugs/feature requests, that are related to the default C generating backend. label May 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This tag is applied to issues which reports bugs. Generics[T] Bugs/feature requests, that are related to the V generics. Unit: cgen Bugs/feature requests, that are related to the default C generating backend.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants