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

Can currently leak private types and values #309

Closed
baszalmstra opened this issue Feb 26, 2021 · 3 comments
Closed

Can currently leak private types and values #309

baszalmstra opened this issue Feb 26, 2021 · 3 comments
Labels
exp: low Achievable with little prior knowledge and guidance good first issue Good for newcomers pri: low An issue with no impact to quality, performance, or functionality

Comments

@baszalmstra
Copy link
Collaborator

Reexporting a type or value from one module to another should check the visibility of the original item.

This can happen in a few cases:

//- foo.mun
// Illegal, Bar has a smaller scope that this use statement
pub(super) struct Bar;

// Illegal, Bar has a smaller scope than this function
pub fn baz() -> Bar {
}
//- mod.mun
pub use foo::Bar; // Should be illegal because Bar is only visible to this module

In rust this emits the error: can't leak private type. This is currently not checked in Mun.

@baszalmstra baszalmstra added good first issue Good for newcomers pri: low An issue with no impact to quality, performance, or functionality exp: low Achievable with little prior knowledge and guidance labels Feb 26, 2021
@mkhan45
Copy link
Contributor

mkhan45 commented Jul 13, 2021

We also need to check that a public struct does not contain any private types in its exported fields:

struct Foo;

pub struct Bar {
    pub foo: Foo // illegal since Foo has a smaller scope than Bar
}

@mkhan45
Copy link
Contributor

mkhan45 commented Aug 14, 2021

this is closed by #338 and #344

@baszalmstra
Copy link
Collaborator Author

Nice! Thanks @mkhan45 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
exp: low Achievable with little prior knowledge and guidance good first issue Good for newcomers pri: low An issue with no impact to quality, performance, or functionality
Projects
None yet
Development

No branches or pull requests

2 participants