Skip to content

feat(parser): accept CONSTANT on VAR_INPUT as a no-op - #1885

Open
volsa wants to merge 1 commit into
masterfrom
vosa/var-input-constant
Open

feat(parser): accept CONSTANT on VAR_INPUT as a no-op#1885
volsa wants to merge 1 commit into
masterfrom
vosa/var-input-constant

Conversation

@volsa

@volsa volsa commented Aug 25, 2026

Copy link
Copy Markdown
Member

Problem: VAR_INPUT CONSTANT was rejected with validation error E034, so sources written for CodeSys did not compile.

Solution: The parser consumes the CONSTANT keyword on VAR_INPUT blocks but drops the flag from the AST, so no constant semantics apply to the members. This is the least invasive way to make the modifier a no-op; keeping the flag would require exemptions in the validator, the indexer, and codegen, where constant propagation would otherwise replace the passed argument with the declared default. A codegen test pins that inputs keep their runtime value.

🤖 Generated with Claude Code

Problem: VAR_INPUT CONSTANT was rejected with E034, so sources written
for CodeSys did not compile.

Solution: The parser consumes the CONSTANT keyword on VAR_INPUT blocks
but drops the flag from the AST; no constant semantics (validation,
constant propagation in codegen) apply to the members.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Aug 25, 2026

Copy link
Copy Markdown

Build Artifacts

🪟 Windows

Artifact Link Size
stdlib.lib Download 4.0 MB
stdlib.dll Download 0.1 MB
plc.exe Download 38.3 MB

From workflow run

🐧 Linux

Artifact Link Size
deb-x86_64 Download 38.4 MB
schema Download 0.0 MB
stdlib Download 32.3 MB
plc-x86_64 Download 43.5 MB
deb-aarch64 Download 30.8 MB
plc-aarch64 Download 43.4 MB

From workflow run

Comment thread src/parser.rs
Comment on lines +1617 to +1619
// XXX: Not particularly clean because the AST no longer reflects the users input, but this
// is the least invasive option making CONSTANT a no-op on VAR_INPUT without touching the
// index, const evaluator, etc.; required due to CodeSys compatibility

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Absolutely hate this plus the fact that a CONSTANT modifier is a no-op 🙃

Comment thread src/parser.rs
let constant = try_consume_var_modifier(lexer, KeywordConstant);
// Ignore the constant flag, i.e. yield false, for VAR_INPUT blocks; no constant semantics
// (validation, codegen) apply to their members
// XXX: Not particularly clean because the AST no longer reflects the users input, but this

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

constant can have a different meaning i think. Would not block this PR but it's worth considering because it popped up before. In C++ a const pointer is expressing intent, this pointer is not going to be changed for this function. i think we can leverage this constant flag exactly like this for validation rules and send it to llvm, add it to the header generation. AFAIK this was even a requested feature for the header generator.

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