feat(parser): accept CONSTANT on VAR_INPUT as a no-op - #1885
Open
volsa wants to merge 1 commit into
Open
Conversation
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>
Build Artifacts🪟 Windows
From workflow run 🐧 Linux
From workflow run |
volsa
commented
Aug 26, 2026
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 |
Member
Author
There was a problem hiding this comment.
Absolutely hate this plus the fact that a CONSTANT modifier is a no-op 🙃
ghaith
reviewed
Aug 26, 2026
| 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 |
Collaborator
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem:
VAR_INPUT CONSTANTwas rejected with validation error E034, so sources written for CodeSys did not compile.Solution: The parser consumes the
CONSTANTkeyword onVAR_INPUTblocks 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