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

checker: fix unwrap when generic structs are used as arguments in uncalled methods(fix #20132) #20135

Merged
merged 1 commit into from Dec 10, 2023

Conversation

shove70
Copy link
Contributor

@shove70 shove70 commented Dec 10, 2023

  1. Fixed Cgen didnt declare type #20132
  2. Add tests.
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]{}
}

outputs:

passed.

@spytheman
Copy link
Member

Good work.

@spytheman spytheman merged commit fe4e1c0 into vlang:master Dec 10, 2023
54 checks passed
@shove70 shove70 deleted the patch-1 branch December 10, 2023 11:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cgen didnt declare type
2 participants