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

fix: Use local variables in property context #1419

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft

Conversation

volsa
Copy link
Member

@volsa volsa commented Mar 1, 2025

refs: https://github.com/PLC-lang/rusty/issues/14174

Edit: Currently the codegen does not ignore property variables, meaning they're still a part of the LLVM POU struct (which affects ffi)

@@ -403,3 +403,38 @@ fn argument_fed_by_ref_then_by_val() {

insta::assert_snapshot!(result)
}

#[test]
fn properties_are_not_registered_as_variables_in_a_pou() {
Copy link
Member Author

Choose a reason for hiding this comment

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

This needs fixing, as the codegen function doesn't make any use of lowering therefore always returning a correct result here.

Comment on lines 692 to 695
if m.is_property() {
// We want to ignore properties
continue;
}
Copy link
Member Author

@volsa volsa Mar 1, 2025

Choose a reason for hiding this comment

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

self-note: Another approach might be removing the internally created property variable after lowering method calls. However, the following code will then no longer return a duplicate symbol error, which is is needed because properties are accessed like variables (e.g. instance.myprop := 5;).

VAR
  foo : DINT
END_VAR

PROPERTY foo : DINT
  // ...
END_PROPERTY

...meaning properties are part of the (IR) POU struct again but at least the tests are working again (still
needs fixing)
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.

1 participant