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

Cgen didnt declare type #20132

Closed
MCausc78 opened this issue Dec 9, 2023 · 0 comments · Fixed by #20135
Closed

Cgen didnt declare type #20132

MCausc78 opened this issue Dec 9, 2023 · 0 comments · Fixed by #20135
Labels
Bug This tag is applied to issues which reports bugs.

Comments

@MCausc78
Copy link
Contributor

MCausc78 commented Dec 9, 2023

Describe the bug

<title>

Reproduction Steps

import time

pub type EventListener[T] = fn (T) !

struct Chan[T] {
	c chan T
}

struct EventWaiter[T] {
	check ?fn (T) bool
	c &Chan[T]
}

pub struct EventController[T] {
mut:
	id int
	wait_fors map[int]EventWaiter[T]
	listeners map[int]EventListener[T]
}

fn (mut ec EventController[T]) generate_id() int {
	return ec.id++
}

@[params]
pub struct EmitOptions {
pub:
	error_handler ?fn (int, IError)
}

pub fn (mut ec EventController[T]) emit(e T, options EmitOptions) {
}

@[params]
pub struct EventWaitParams[T] {
pub:
	check ?fn (T) bool
	timeout ?time.Duration
}

pub fn (mut ec EventController[T]) wait[T](params EventWaitParams[T]) ?T {
	return none
}

pub fn (mut ec EventController[T]) override[T](listener EventListener[T]) EventController[T] {
	return ec
}

pub fn (mut ec EventController[T]) listen[T](listener EventListener[T]) EventController[T] {
	return ec
}

fn main() {
	ec := EventController[int]{}
}

Expected Behavior

Successful compile

Current Behavior

PS D:\Games\Proekti\V\interactions> v -cg run repro.v
repro.v:54:2: warning: unused variable: `ec`
   52 |
   53 | fn main() {
   54 |     ec := EventController[int]{}
      |     ~~
   55 | }
C:/Users/mclr/AppData/Local/Temp/v_0/repro.17533198570123215954.tmp.c:540: warning: WINVER redefined
C:/Users/mclr/AppData/Local/Temp/v_0/repro.17533198570123215954.tmp.c:942: warning: InterlockedIncrement64 redefined
In file included from C:/Users/mclr/AppData/Local/Temp/v_0/repro.17533198570123215954.tmp.c:1199:
d:/games/proekti/v/v/thirdparty/tcc/include/winapi/synchapi.h:13: warning: CreateEvent redefined
In file included from C:/Users/mclr/AppData/Local/Temp/v_0/repro.17533198570123215954.tmp.c:1199:
d:/games/proekti/v/v/thirdparty/tcc/include/winapi/synchapi.h:117: warning: OpenEvent redefined
In file included from C:/Users/mclr/AppData/Local/Temp/v_0/repro.17533198570123215954.tmp.c:1199:
d:/games/proekti/v/v/thirdparty/tcc/include/winapi/synchapi.h:167: warning: CreateMutex redefined
C:/Users/mclr/AppData/Local/Temp/v_0/repro.17533198570123215954.tmp.c:3051: error: invalid 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

Possible Solution

No response

Additional Information/Context

No response

V version

V 0.4.3 08189d6

Environment details (OS name and version, etc.)

V full version: V 0.4.3 140c838.08189d6
OS: windows, Microsoft Windows 11 Pro v22000 64-bit
Processor: 12 cpus, 64bit, little endian, 

getwd: D:\Games\Proekti\V\interactions
vexe: D:\Games\Proekti\V\v\v.exe
vexe mtime: 2023-12-09 09:55:27

vroot: OK, value: D:\Games\Proekti\V\v
VMODULES: OK, value: C:\Users\mclr\.vmodules
VTMP: OK, value: C:\Users\mclr\AppData\Local\Temp\v_0

Git version: git version 2.37.0.windows.1
Git vroot status: weekly.2023.48-76-g08189d64
.git/config present: true

CC version:
thirdparty/tcc status: thirdparty-windows-amd64 e90c2620

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.

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.
Projects
None yet
1 participant