Skip to content
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

Channel instantiation with generic type is failing compilation #19609

Closed
prashanth-hegde opened this issue Oct 20, 2023 · 0 comments · Fixed by #19993
Closed

Channel instantiation with generic type is failing compilation #19609

prashanth-hegde opened this issue Oct 20, 2023 · 0 comments · Fixed by #19993
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

@prashanth-hegde
Copy link
Contributor

prashanth-hegde commented Oct 20, 2023

Describe the bug

When a channel is created with a generic type, there's a compilation error being thrown

Reproduction Steps

struct Task[T] {
	idx		int 
	task	T
}

fn check[T](input T) T {
	ch := chan Task[T]{} // replacing T with `int` compiles fine
	// do something with channel
	ch.close()
	return input
}

fn main() {
	out := check[int](5)
	println(out)
}

Expected Behavior

Channel is created without error

Current Behavior

Getting this build error

==================
/tmp/v_1000/x.8129215833272495033.tmp.c:1485: error: identifier expected
...
==================
(Use `v -cg` to print the entire error message)

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

Possible Solution

No response

Additional Information/Context

No response

V version

V 0.4.2 7e3d737

Environment details (OS name and version, etc.)

MacOs M1 Ventura 13.4.1

Note

You can vote for this issue using the 👍 reaction. More votes increase the issue's priority for developers.

Take into account that only the 👍 reaction counts as a vote.
Only reactions to the issue itself will be counted as votes, not comments.

@prashanth-hegde prashanth-hegde added the Bug This tag is applied to issues which reports bugs. label Oct 20, 2023
@ArtemkaKun ArtemkaKun added 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. Build V build error on any OS/CPU architecture. labels Oct 21, 2023
@felipensp felipensp removed the Build V build error on any OS/CPU architecture. label Nov 25, 2023
@felipensp felipensp self-assigned this Nov 25, 2023
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.

3 participants