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

Fails to deduce generic type when spawning a thread inside a generic function #22484

Closed
CG-SS opened this issue Oct 11, 2024 · 0 comments · Fixed by #22491
Closed

Fails to deduce generic type when spawning a thread inside a generic function #22484

CG-SS opened this issue Oct 11, 2024 · 0 comments · Fixed by #22491
Assignees
Labels
Bug This tag is applied to issues which reports bugs. Status: Confirmed This bug has been confirmed to be valid by a contributor. Unit: cgen Bugs/feature requests, that are related to the default C generating backend. Unit: Type System Bugs/feature requests, that are related to the V types system.

Comments

@CG-SS
Copy link

CG-SS commented Oct 11, 2024

Describe the bug

It appers the C generation fails when a generic function tries to spawn a thread for another generic function with a channel.

Reproduction Steps

Run the program:

module main

struct In[T] {
	source chan T
}

fn emit[T](s In[T], ar []T) {
	for _, i in ar {
		s.source <- i
	}
}

fn from[T](ar []T) In[T] {
	s := In[T]{}

	spawn emit(s, ar)

	return s
}

fn (i In[T]) get() T {
	return <-i.source
}

fn main() {
	v := from[int]([1]).get()

	println(v)
}

Expected Behavior

Should print 1.

Current Behavior

================== C compilation error (from tcc): ==============
cc: c:/users/erlin/v/thirdparty/tcc/include/winapi/synchapi.h:167: warning: CreateMutex redefined
cc: C:/Users/erlin/AppData/Local/Temp/v_0/main.exe.01J9WN0TA44PBED7GV3X6K2MF6.tmp.c:2075: error: 'T' undeclared
... (the original output was 9 lines long, and was truncated to 2 lines)
=================================================================
(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.

Possible Solution

No response

Additional Information/Context

No response

V version

V 0.4.8 18eee34.2ca3fdf

Environment details (OS name and version, etc.)

V full version: V 0.4.8 18eee34.2ca3fdf
OS: windows, Microsoft Windows 11 Pro v22631 64-bit
Processor: 32 cpus, 64bit, little endian

Git version: git version 2.42.0.windows.2
Git vroot status: 0.4.8-87-g2ca3fdfa-dirty
.git/config present: true

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.

@CG-SS CG-SS added the Bug This tag is applied to issues which reports bugs. label Oct 11, 2024
@felipensp felipensp self-assigned this Oct 11, 2024
@felipensp felipensp added Unit: cgen Bugs/feature requests, that are related to the default C generating backend. Unit: Type System Bugs/feature requests, that are related to the V types system. labels Oct 11, 2024
@felipensp felipensp added the Status: Confirmed This bug has been confirmed to be valid by a contributor. label Oct 11, 2024
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. Status: Confirmed This bug has been confirmed to be valid by a contributor. Unit: cgen Bugs/feature requests, that are related to the default C generating backend. Unit: Type System Bugs/feature requests, that are related to the V types system.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants