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

#659 array of struct initialization #663

Merged
merged 5 commits into from
Nov 29, 2022

Conversation

99NIMI
Copy link
Member

@99NIMI 99NIMI commented Nov 24, 2022

The problem we got is how we generate STRUCTs
for STRUCTs we got an ExpressionList with Assignments for the fields
When we try to initialize an ARRAY we performed flatten_expression_list on the passed initializer to get rid of the first ExpressionList (because ARRAY initializer will always be an ExpressionList)
This will return a vector of Assignments, leading to the problem we got

Solution:
For ARRAY of STRUCT get rid of the first ExpressionList and work with the contained vector of AstStatements, this will preserve the ExpressionLists of Assignments for STRUCTs

@99NIMI 99NIMI requested review from ghaith, riederm and mhasel November 24, 2022 12:27
@99NIMI 99NIMI linked an issue Nov 24, 2022 that may be closed by this pull request
@codecov-commenter
Copy link

codecov-commenter commented Nov 24, 2022

Codecov Report

Base: 93.90% // Head: 93.93% // Increases project coverage by +0.03% 🎉

Coverage data is based on head (79e09c7) compared to base (3dc10fb).
Patch coverage: 92.85% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #663      +/-   ##
==========================================
+ Coverage   93.90%   93.93%   +0.03%     
==========================================
  Files          46       46              
  Lines       17938    17964      +26     
==========================================
+ Hits        16844    16874      +30     
+ Misses       1094     1090       -4     
Impacted Files Coverage Δ
src/codegen/generators/expression_generator.rs 89.66% <90.90%> (+0.30%) ⬆️
src/resolver.rs 97.51% <94.11%> (-0.05%) ⬇️
src/parser/expressions_parser.rs 93.84% <0.00%> (-0.13%) ⬇️
src/validation.rs 98.32% <0.00%> (+0.27%) ⬆️

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.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Collaborator

@riederm riederm left a comment

Choose a reason for hiding this comment

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

good job, I really thought this would be much more complicated when I saw the issue.

I did a quick test regarding the comment about the get_effective_type(...). Can you verify that it solves the problem?

btw. I added the situation to your unit test and I think it fails.

@@ -3774,3 +3774,50 @@ fn multiple_negative_annotates_correctly() {
}
}
}

#[test]
fn array_of_struct_with_inital_values_annotated_correctly() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍 I like your thoughtful testing!

@99NIMI 99NIMI requested a review from riederm November 28, 2022 06:18
@99NIMI 99NIMI merged commit 3150be6 into master Nov 29, 2022
@99NIMI 99NIMI deleted the 659-array-of-struct-initialization-problem branch November 29, 2022 06:02
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.

array of struct - no type hint available for Assignment
3 participants