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 calling method on or block result in if expression #20044

Closed
ttytm opened this issue Nov 30, 2023 · 0 comments · Fixed by #20094
Closed

Builder error when calling method on or block result in if expression #20044

ttytm opened this issue Nov 30, 2023 · 0 comments · Fixed by #20094
Assignees
Labels
Bug This tag is applied to issues which reports bugs. Unit: cgen Bugs/feature requests, that are related to the default C generating backend.

Comments

@ttytm
Copy link
Member

ttytm commented Nov 30, 2023

Describe the bug

fn baz(str string) !string {
	return str
}

foo := '/bar'
bar := if foo.contains('foo') {
	foo.all_after('foo')
} else {
	baz(foo) or { panic('panic') }.trim_left('/') // method call causes builder error
}

assert bar == 'bar'

Reproduction Steps

above

Expected Behavior

works

Current Behavior

builder error

Possible Solution

A possible workaround is calling the method on a variable that was assigned beforehand

bar := if foo.contains('foo') {
	foo.all_after('foo')
} else {
	b := baz(foo) or { panic('panic') }
	b.trim_left('/')
}

No response

Additional Information/Context

No response

V version

V 0.4.3

Environment details (OS name and version, etc.)

linux, amd64

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 Nov 30, 2023
@felipensp felipensp added the Unit: cgen Bugs/feature requests, that are related to the default C generating backend. label Nov 30, 2023
@shove70 shove70 self-assigned this Dec 5, 2023
shove70 added a commit to shove70/v that referenced this issue Dec 5, 2023
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. Unit: cgen Bugs/feature requests, that are related to the default C generating backend.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants