feat: function privacy leak validator#338
Conversation
crates/mun_hir/src/expr/validator.rs
Outdated
|
|
||
| param_types | ||
| .chain(std::iter::once(ret_ty)) | ||
| .filter(type_is_not_allowed) |
There was a problem hiding this comment.
add .take(1) to show only a single diagnostic per function
|
Thanks for this! Would it be possible to highlight the region of the type thas has a more private type? So in the case of: |
3e72c8b to
36c93d8
Compare
|
Alright, I've changed the diagnostic to highlight the type, but it's a bit harder to make it actually display the type name in the diagnostic message. I don't think it's a big deal since the name is highlighted anyway though. |
|
You can implement something in The goal of Adding the name is not required perse but I think it will provide users with a much better experience down the road. |
Codecov Report
@@ Coverage Diff @@
## master #338 +/- ##
==========================================
+ Coverage 80.24% 80.30% +0.06%
==========================================
Files 258 259 +1
Lines 15572 15637 +65
==========================================
+ Hits 12496 12558 +62
- Misses 3076 3079 +3
Continue to review full report at Codecov.
|
36c93d8 to
0f52b00
Compare
|
I've added a |
Wodann
left a comment
There was a problem hiding this comment.
Looks good overall. I had one question
|
|
||
| impl Diagnostic for ExportedPrivate { | ||
| fn message(&self) -> String { | ||
| "can't leak private type".to_string() |
There was a problem hiding this comment.
We have duplication of this error message. Is there a way to reuse it to avoid code+paste errors?
Other occurance:
https://github.com/mun-lang/mun/pull/338/files#diff-7a57632f7acc9a0b1abad5ef6f9447f95fabecf03312d0ab7d0597807ae8e25dR24
0f52b00 to
070807b
Compare
|
I've updated it so that there's no duplication |
Added a validation for privacy leaks in function signatures, added a few tests, and updated existing tests/examples
070807b to
f0a27e3
Compare

Part of #309
Adds a validation for leaking private types from function signatures