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

mutable params struct not optional as function argument #21205

Closed
ttytm opened this issue Apr 6, 2024 · 0 comments · Fixed by #21206
Closed

mutable params struct not optional as function argument #21205

ttytm opened this issue Apr 6, 2024 · 0 comments · Fixed by #21206
Assignees
Labels
Bug This tag is applied to issues which reports bugs.

Comments

@ttytm
Copy link
Member

ttytm commented Apr 6, 2024

Describe the bug

module main

@[params]
struct Params {
mut:
	a bool
}

fn foo(mut opts Params) {
	// ... processing, goal is to eventually have it accessible inside the function, recursively using it.
	// opts.a = true
	// foo(opts)
	println('')
}

fn main() {
	foo()
	// Below works.
	// mut p := Params{a: 1}
	// foo(mut p)

}

Reproduction Steps

above

Expected Behavior

params optionally passing params struct

Current Behavior

error: function `foo` parameter `opts` is `mut`, so use `mut Params{....}` instead
    1 | module main
      | ^
    2 | 
    3 | @[params]

Possible Solution

No response

Additional Information/Context

No response

V version

v0.4.5

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 Apr 6, 2024
@ttytm ttytm self-assigned this Apr 6, 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

Successfully merging a pull request may close this issue.

1 participant