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

checker: check error of implementing other module private interface (fix #19620) #19688

Merged
merged 2 commits into from
Oct 29, 2023

Conversation

yuyi98
Copy link
Member

@yuyi98 yuyi98 commented Oct 28, 2023

This PR check error of implementing other module private interface (fix #19620).

  • Check error of implementing other module private interface.
  • Add test.
// sub module
module baz

interface Foo {
	a int
}

pub fn print_foo(f Foo) {
	println(f.a)
}
module main
import baz

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

struct Bar {
	a int
}

PS D:\Test\v\tt1> v run .    
tt1.v:6:16: error: `Bar` cannot implement private interface `baz.Foo` of other module
    4 | fn main() {
    5 |     b := Bar{10}
    6 |     baz.print_foo(b) // prints 10
      |                   ^
    7 | }
    8 |

Copy link
Member

@spytheman spytheman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent work.

@spytheman spytheman merged commit 7681a0b into vlang:master Oct 29, 2023
53 checks passed
@yuyi98 yuyi98 deleted the check_private_interface branch October 29, 2023 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Structs in other modules should not be able to implement private interfaces
2 participants