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 sumtype with reference (fix #21721) #21730

Merged
merged 1 commit into from
Jun 25, 2024

Conversation

yuyi98
Copy link
Member

@yuyi98 yuyi98 commented Jun 25, 2024

This PR fix sumtype with reference (fix #21721).

  • Fix sumtype with reference.
  • Add test.
struct Parse {
mut:
	stack []&Element
}

struct Balise {}

struct RawText {
	s string
}

type Element = Balise | RawText

fn (mut p Parse) process_open_tag() string {
	mut last := &p.stack[0]
	if mut last is RawText {
		println(last)
		return last.s
	} else {
		return ''
	}
}

fn main() {
	mut parse := Parse{
		stack: [&RawText{'raw'}]
	}
	assert parse.process_open_tag() == 'raw'
}

PS D:\Test\v\tt1> v run .
RawText{
    s: 'raw'
}

@spytheman spytheman merged commit 98a1ee2 into vlang:master Jun 25, 2024
76 checks passed
@yuyi98 yuyi98 deleted the fix_multi_ptr_is_operate branch June 25, 2024 08:00
raw-bin pushed a commit to raw-bin/v that referenced this pull request Jul 2, 2024
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: struct or union expected
2 participants