Skip to content

enum initialization in var-blocks#904

Merged
mhasel merged 3 commits intomasterfrom
fix-enum-assignment-in-var-block
Jul 23, 2023
Merged

enum initialization in var-blocks#904
mhasel merged 3 commits intomasterfrom
fix-enum-assignment-in-var-block

Conversation

@mhasel
Copy link
Copy Markdown
Member

@mhasel mhasel commented Jul 13, 2023

Fixes invalid enum initializers not being validated. I've also reclassified the severity from ImprovementSuggestion to SemanticError. Consider the following example:

PROGRAM prog
VAR
    x : DINT := 12345;
    var3 : (a, b, c) := 7; // this should not just be a warning
END_VAR
    var3 := x; // and neither should this
END_PROGRAM

While we could validate against a literal initializer out of range, doing so for a reference is a different story.

@mhasel mhasel requested review from ghaith and volsa July 13, 2023 12:26
@mhasel mhasel linked an issue Jul 13, 2023 that may be closed by this pull request
@codecov
Copy link
Copy Markdown

codecov Bot commented Jul 13, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.03 🎉

Comparison is base (bcf5f7f) 95.93% compared to head (2f6920e) 95.97%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #904      +/-   ##
==========================================
+ Coverage   95.93%   95.97%   +0.03%     
==========================================
  Files         118      118              
  Lines       38569    38608      +39     
==========================================
+ Hits        37002    37054      +52     
+ Misses       1567     1554      -13     
Impacted Files Coverage Δ
src/diagnostics.rs 80.13% <100.00%> (+0.02%) ⬆️
src/validation/statement.rs 92.49% <100.00%> (+0.06%) ⬆️
src/validation/variable.rs 91.37% <100.00%> (+1.94%) ⬆️

... and 6 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Copy Markdown
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

@mhasel mhasel merged commit 0b23cd1 into master Jul 23, 2023
@mhasel mhasel deleted the fix-enum-assignment-in-var-block branch July 23, 2023 11:04
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.

enum declaration in VAR block

2 participants