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

Structs in other modules should not be able to implement private interfaces #19620

Closed
2 tasks
Trakis196 opened this issue Oct 22, 2023 · 0 comments · Fixed by #19688
Closed
2 tasks

Structs in other modules should not be able to implement private interfaces #19620

Trakis196 opened this issue Oct 22, 2023 · 0 comments · Fixed by #19688
Labels
Feature Request This issue is made to request a feature. Unit: Type System Bugs/feature requests, that are related to the V types system.

Comments

@Trakis196
Copy link

Trakis196 commented Oct 22, 2023

Describe the feature

Private structs are not able to be initialized or have their fields accessed from another module, however private interfaces are able to be implemented from another module and used in function arguments for that interface. For example:

// main.v
module main
import baz

fn main() {
	b := Bar{10}
	baz.print_foo(b) // prints 10
}

struct Bar {
	a int
}

// sub module
module baz

interface Foo {
	a int
}

pub fn print_foo(f Foo) {
	println(f.a)
}

Use Case

To be consistent with private structs, and to constrain interfaces to a specific module they are in if they are private.

Proposed Solution

No response

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

Version used

V 0.4.2 48a1d6c

Environment details (OS name and version, etc.)

OS: linux, "Arch Linux"
Processor: 8 cpus, 64bit, little endian, 11th Gen Intel(R) Core(TM) i5-1135G7 @ 2.40GHz
Git version: git version 2.42.0
Git vroot status: weekly.2023.23-837-g48a1d6cc-dirty
.git/config present: true
CC version: cc (GCC) 13.2.1 20230801
thirdparty/tcc status: thirdparty-linux-amd64 12f392c3

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.

@Trakis196 Trakis196 added the Feature Request This issue is made to request a feature. label Oct 22, 2023
@ArtemkaKun ArtemkaKun added the Unit: Type System Bugs/feature requests, that are related to the V types system. label Oct 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Request This issue is made to request a feature. Unit: Type System Bugs/feature requests, that are related to the V types system.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants