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

feat: support referencing local variables in pointer initialization #1346

Merged
merged 14 commits into from
Oct 29, 2024

Conversation

mhasel
Copy link
Member

@mhasel mhasel commented Oct 22, 2024

Adds support to initialize pointer, alias and reference-to variables with the address of local POU members.
The only exception is that stateful members cannot be initialized with addresses of temporary values, since 1) they do not exist at the time of initialization and 2) would lead to dangling pointers after going out of scope.

@mhasel mhasel marked this pull request as ready for review October 23, 2024 14:56
src/lowering.rs Outdated Show resolved Hide resolved
Copy link

codecov bot commented Oct 24, 2024

Codecov Report

Attention: Patch coverage is 93.83562% with 9 lines in your changes missing coverage. Please review.

Project coverage is 91.41%. Comparing base (be78df6) to head (0c4c94e).
Report is 115 commits behind head on master.

Files with missing lines Patch % Lines
src/validation/variable.rs 90.24% 4 Missing ⚠️
compiler/plc_driver/src/lib.rs 66.66% 3 Missing ⚠️
src/codegen/generators/expression_generator.rs 0.00% 1 Missing ⚠️
src/lowering.rs 98.24% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1346      +/-   ##
==========================================
+ Coverage   91.11%   91.41%   +0.29%     
==========================================
  Files         153      160       +7     
  Lines       44816    49660    +4844     
==========================================
+ Hits        40833    45395    +4562     
- Misses       3983     4265     +282     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@volsa volsa left a comment

Choose a reason for hiding this comment

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

Looks good, just missing a new error code

src/validation/variable.rs Outdated Show resolved Hide resolved
@mhasel mhasel requested a review from volsa October 29, 2024 07:59
Copy link
Member

@volsa volsa left a comment

Choose a reason for hiding this comment

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

Nice!

@mhasel mhasel merged commit 8a07316 into master Oct 29, 2024
21 checks passed
@mhasel mhasel deleted the local-refs branch October 29, 2024 08:48
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.

2 participants