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

Generic struct can't be used as shared method parameter #19804

Closed
ArtemkaKun opened this issue Nov 7, 2023 · 0 comments · Fixed by #19805
Closed

Generic struct can't be used as shared method parameter #19804

ArtemkaKun opened this issue Nov 7, 2023 · 0 comments · Fixed by #19805
Assignees
Labels
Bug This tag is applied to issues which reports bugs. Generics[T] Bugs/feature requests, that are related to the V generics. Unit: Parser Bugs/feature requests, that are related to the V parser or syntax (*not* semantic ones).

Comments

@ArtemkaKun
Copy link
Contributor

ArtemkaKun commented Nov 7, 2023

Describe the bug

The error will be thrown if you will try to have a method with a generic struct parameter marked as shared. This shouldn't produce any error.

Reproduction Steps

struct Test[T] {
	value T
}

fn do_something(shared stuff Test[int]) {
	rlock {
		println(stuff.value)
	}
}

shared test := Test[int]

do_something(test)

Expected Behavior

No error, console outputs 0

Current Behavior

code.v:5:30: error: shared arguments are only allowed for arrays, maps, and structs

    3 | }
    4 | 
    5 | fn do_something(shared stuff Test[int]) {
      |                              ~~~~
    6 |     rlock {
    7 |         println(stuff.value)

Possible Solution

No response

Additional Information/Context

No response

V version

V 0.4.2 fae46a8

Environment details (OS name and version, etc.)

Playground

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.

@ArtemkaKun ArtemkaKun added Bug This tag is applied to issues which reports bugs. Generics[T] Bugs/feature requests, that are related to the V generics. Unit: Checker Bugs/feature requests, that are related to the type checker. labels Nov 7, 2023
@shove70 shove70 self-assigned this Nov 7, 2023
@shove70 shove70 added Unit: Parser Bugs/feature requests, that are related to the V parser or syntax (*not* semantic ones). and removed Unit: Checker Bugs/feature requests, that are related to the type checker. labels Nov 7, 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. Generics[T] Bugs/feature requests, that are related to the V generics. Unit: Parser Bugs/feature requests, that are related to the V parser or syntax (*not* semantic ones).
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants