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: fix codegen for match with sumtype ptrptr #23785

Merged
merged 2 commits into from
Feb 22, 2025

Conversation

felipensp
Copy link
Member

Fix #23776

Copy link

Connected to Huly®: V_0.6-22196

Copy link
Member

@spytheman spytheman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent work.

@spytheman
Copy link
Member

The second example from the issue:

pub type Command = Assign | Call

pub struct Assign {}

pub struct Call {
mut:
	text string
}

fn main() {
	mut command_arr_ptr := [ &Command(Call{}) ]
	mut command_arr_el_ptr := command_arr_ptr[0]
	println(typeof(command_arr_el_ptr)) // builder error: expected struct or union but not 'struct main__Command *'
}

still fails.

Should I re-open the issue after merging this PR?

@Delta456
Copy link
Member

How about we make another issue with this code sample? That seems like a better idea to me.

@felipensp
Copy link
Member Author

Yes, I think we should split the issues.

@felipensp felipensp marked this pull request as ready for review February 22, 2025 12:39
Copy link
Member

@Delta456 Delta456 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work

@felipensp
Copy link
Member Author

The second example from the issue:

pub type Command = Assign | Call

pub struct Assign {}

pub struct Call {
mut:
	text string
}

fn main() {
	mut command_arr_ptr := [ &Command(Call{}) ]
	mut command_arr_el_ptr := command_arr_ptr[0]
	println(typeof(command_arr_el_ptr)) // builder error: expected struct or union but not 'struct main__Command *'
}

still fails.

Should I re-open the issue after merging this PR?

Pushed a fix for the second example.

@spytheman spytheman merged commit ffdc1ab into vlang:master Feb 22, 2025
72 checks passed
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.

builder error: Incorrect type inference and pattern matching for pointers to sum type elements
3 participants