-
Notifications
You must be signed in to change notification settings - Fork 56
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
354 duplicate functions should be a problem #622
Conversation
The symbolmap is an IndexMap<K, Vec<V>> that allows the index to store more than one entry for a given name. It is manually implemented (in favor of a MultiMap-Crate) because the MultiMap crates that I tested would mix the order of stuff in the index dramatically wich would: 1) create a huuuge change in .snaps that are very hard to verify 2) obfuscate the resulting IR by arbitrarily mixing the symbols (indexMap has a stable orderung)
introduced SymbolMap which is a simple yet stable (order) Multimap that would not change the huge number of snapshot-tests by changing the order of generated symbols (like the multimap crate does)
the first location is used as the primary label, the rest of the locations are treated as secondary labels.
the first location is used as the primary label, the rest of the locations are treated as secondary labels.
simplified validation code
…/github.com/PLC-lang/rusty into 354-duplicate-functions-should-be-a-problem
SourceMap moved to its own file to reduce the size of index.rs
Codecov ReportBase: 93.70% // Head: 93.78% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## master #622 +/- ##
==========================================
+ Coverage 93.70% 93.78% +0.07%
==========================================
Files 44 46 +2
Lines 16846 17460 +614
==========================================
+ Hits 15786 16374 +588
- Misses 1060 1086 +26
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it
I think it might make sense to try the iterator generic to avoid the needless collection and add the test to cover a global variable clashing with POUs i seem to have missed it.
src/lib.rs
Outdated
// ### PHASE 2 ### | ||
// annotation & validation everything | ||
let mut annotated_units: Vec<CompilationUnit> = Vec::new(); | ||
let mut all_annotations = AnnotationMapImpl::default(); | ||
let mut all_literals = StringLiterals::default(); | ||
for (file_id, syntax_errors, unit) in all_units.into_iter() { | ||
//todo get rid of the file_id | ||
for (_, syntax_errors, unit) in all_units.into_iter() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not do that already? Too many changes/test changes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm ... I forgot that ... I'll give it a try
@@ -0,0 +1,202 @@ | |||
use crate::{ast::SourceRange, diagnostics::Diagnostic, test_utils::tests::parse_and_validate}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some more examples:
A global variable and a program with the same name
A global function block instance and a function of the same name
- check uniqueness of everything callable - check uniqueness of everything that can be a variable-access - check uniqueness of everything that can be used as a Type - check uniqueness of POUs added additional tests to cover corner-cases
eec5e99
to
338654c
Compare
…ould-be-a-problem
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
Introduced SymbolMap which is a MultiMap that keeps the insertion order alive when iterating the elements. That way we keep exisiting tests working (I tried the multimap-create and it mixes up the order of stuff in the index which results in different order of elements generated in IR, so basically 80% of all tests would require a review).
Furthermore I introduced the global_validator.rs which validates stuff using the index. This commit extends Diagnostics to more than one location. first location remains the diagnostics main location, following locations are treated as secondary/see-also hints.
fixes #285
fixes #354
fixes #602