Skip to content

fix(variables): accept byte (BYTE/SINT/USINT) IEC locations; revert to 4.2.9#963

Merged
thiagoralves merged 1 commit into
developmentfrom
bugfix/iec-all-locations
Jul 25, 2026
Merged

fix(variables): accept byte (BYTE/SINT/USINT) IEC locations; revert to 4.2.9#963
thiagoralves merged 1 commit into
developmentfrom
bugfix/iec-all-locations

Conversation

@thiagoralves

@thiagoralves thiagoralves commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Completes IEC location coverage in the variable-table validator.

Change

  • Add BYTE_LOCATION_REGEX = /^%[QIM]B\d+$/ and handle BYTE/SINT/USINT → byte addressing (%IB/%QB/%MB), matching strucpp and the runtime image tables. This closes the last size-class gap (X/B/W/D/L now all supported across I/Q/M).
  • %MB (memory byte) is accepted even though the runtime doesn't back it yet — strucpp compiles it; a byte_memory runtime buffer will follow separately.
  • Time/date elementary types (TIME/DATE/TOD/DT) remain unlocated by design.
  • Reverts APP_VERSION + package.json 4.2.10 → 4.2.9 — this is a small fix folded into the 4.2.9 line, not a separate release.

Verification

  • Unit tests: %IB/%QB/%MB accepted for BYTE/SINT/USINT; cross-width locations still rejected.
  • Browser-tested in openplc-web: a BYTE variable accepts %MB0.

Backed by an end-to-end check: strucpp's lexer/compiler accept all [IQM][XBWDL] forms, and the runtime image tables back every combination except %MB (tracked for a follow-up runtime fix).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Improved validation for BYTE, SINT, and USINT PLC variable locations.
    • Added support for valid input, output, and memory byte addresses.
    • Invalid address types are now correctly rejected with clearer guidance.
  • Tests

    • Expanded validation coverage for valid and invalid byte-sized address combinations.
  • Chores

    • Updated the application version to 4.2.9.

Complete the IEC location coverage: add %[QIM]B byte addressing for the
8-bit elementary types (BYTE, SINT, USINT), matching strucpp and the
runtime image tables (which back %IB/%QB). %MB (memory byte) is accepted
too — strucpp compiles it; a runtime byte_memory buffer will follow.
Time/date types (TIME/DATE/TOD/DT) remain unlocated by design.

Verified in openplc-web: a BYTE var accepts %MB0; cross-width locations
(e.g. %IX on a byte type) are still rejected.

Revert APP_VERSION + package.json 4.2.10 -> 4.2.9: this location work is a
small fix folded into the 4.2.9 line, not a separate release.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

The application version is changed from 4.2.10 to 4.2.9. PLC address mappings and validation are extended for BYTE-family variable types, with tests covering valid byte locations and invalid cross-width locations.

Changes

BYTE location validation

Layer / File(s) Summary
BYTE address contract
src/frontend/utils/PLC/address-constants/types.ts
Adds byte-area prefixes and exports BYTE_LOCATION_REGEX for input, output, and memory addresses.
BYTE variable validation
src/frontend/store/slices/project/validation/variables.ts, src/frontend/store/__tests__/project-validation-variables.test.ts
Validates BYTE, SINT, and USINT locations with the byte regex, updates error messages, and adds valid and cross-width location tests.

Application version alignment

Layer / File(s) Summary
Version value updates
package.json, src/frontend/data/constants/app-version.ts
Changes both application version values from 4.2.10 to 4.2.9.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested reviewers: dcoutinho1328, joaogsp

Poem

I’m a bunny with byte-sized cheer,
New PLC paths are hopping clear.
Versions align in a neat little line,
Tests guard each address design.
Carrots and code now both compile fine!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive The description covers the change and verification, but it omits the template's References and DOD checklist sections. Add the missing References and DOD checklist sections, or note that they are not applicable, to match the repository template.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main changes: byte-location support and the version revert to 4.2.9.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch bugfix/iec-all-locations

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/frontend/utils/PLC/address-constants/types.ts`:
- Around line 19-24: Update the comments above the IEC size-class definitions to
distinguish validator support from runtime backing: state that the prefixes are
accepted by validation, while clarifying that %MB is intentionally accepted but
not currently supported by the runtime because byte_memory is absent. Remove the
contradictory claim that all three areas match runtime support.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 032d53de-fa0f-430b-b92e-a3a1e7666ea3

📥 Commits

Reviewing files that changed from the base of the PR and between 0335117 and fe85fe3.

📒 Files selected for processing (5)
  • package.json
  • src/frontend/data/constants/app-version.ts
  • src/frontend/store/__tests__/project-validation-variables.test.ts
  • src/frontend/store/slices/project/validation/variables.ts
  • src/frontend/utils/PLC/address-constants/types.ts

Comment on lines +19 to +24
// Each IEC size class accepts all three area prefixes — input (I), output (Q)
// and memory (M) — matching what strucpp and the runtime image tables support:
// X = bit (BOOL), B = byte (BYTE/SINT/USINT), W = word (INT/UINT/WORD),
// D = dword (DINT/UDINT/REAL/DWORD), L = lword (LINT/ULINT/LREAL/LWORD).
// NOTE: %MB (memory byte) is accepted here even though the runtime does not
// yet back it (no byte_memory buffer) — a runtime fix is planned separately.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Correct the runtime-support claim in the documentation.

Lines 20 and 23-24 contradict each other: the first says all three areas match runtime support, while the latter says %MB has no runtime byte_memory buffer. Clarify that %MB is intentionally validator-supported but not runtime-backed yet.

Proposed wording
-// and memory (M) — matching what strucpp and the runtime image tables support:
+// and memory (M); strucpp supports all three, but the runtime does not yet
+// provide a byte_memory buffer for %MB:
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// Each IEC size class accepts all three area prefixes — input (I), output (Q)
// and memory (M) — matching what strucpp and the runtime image tables support:
// X = bit (BOOL), B = byte (BYTE/SINT/USINT), W = word (INT/UINT/WORD),
// D = dword (DINT/UDINT/REAL/DWORD), L = lword (LINT/ULINT/LREAL/LWORD).
// NOTE: %MB (memory byte) is accepted here even though the runtime does not
// yet back it (no byte_memory buffer) — a runtime fix is planned separately.
// Each IEC size class accepts all three area prefixes — input (I), output (Q)
// and memory (M); strucpp supports all three, but the runtime does not yet
// provide a byte_memory buffer for %MB:
// X = bit (BOOL), B = byte (BYTE/SINT/USINT), W = word (INT/UINT/WORD),
// D = dword (DINT/UDINT/REAL/DWORD), L = lword (LINT/ULINT/LREAL/LWORD).
// NOTE: %MB (memory byte) is accepted here even though the runtime does not
// yet back it (no byte_memory buffer) — a runtime fix is planned separately.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/frontend/utils/PLC/address-constants/types.ts` around lines 19 - 24,
Update the comments above the IEC size-class definitions to distinguish
validator support from runtime backing: state that the prefixes are accepted by
validation, while clarifying that %MB is intentionally accepted but not
currently supported by the runtime because byte_memory is absent. Remove the
contradictory claim that all three areas match runtime support.

@thiagoralves
thiagoralves merged commit 89998a1 into development Jul 25, 2026
14 checks passed
@thiagoralves
thiagoralves deleted the bugfix/iec-all-locations branch July 25, 2026 15:38
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