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

builder error: when using selector expression on expression (missing autoderef in method?) #21309

Open
ttytm opened this issue Apr 18, 2024 · 0 comments
Labels
Bug This tag is applied to issues which reports bugs.

Comments

@ttytm
Copy link
Member

ttytm commented Apr 18, 2024

Describe the bug

struct Foo {
	str string
}

// fn (f Foo) foo(f2 Foo) string { // would work, since no autoref when not mut?
// fn (f &Foo) foo(f2 Foo) string { // same error
fn (mut f Foo) foo(f2 Foo) string {
	return if f.str != '' { f } else { f2 }.str
	// return if f.str != '' { *f } else { f2 }.str // currently a manual deref is required
}

fn main() {
	mut foo := Foo{}
	dump(foo.foo(Foo{str: 'a'}))
}

Reproduction Steps

above

Expected Behavior

works

Current Behavior

error: type mismatch in conditional expression (have 'struct main__Foo *' and 'struct main__Foo')
...

builder error: 
==================
C error. This should never happen.

Possible Solution

No response

Additional Information/Context

No response

V version

v0.4.5

Environment details (OS name and version, etc.)

linux amd-x64

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.

@ttytm ttytm added the Bug This tag is applied to issues which reports bugs. label Apr 18, 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.
Projects
None yet
Development

No branches or pull requests

1 participant