Skip to content

feat: Validations for polymorphism#1630

Open
volsa wants to merge 4 commits intomasterfrom
vosa/polymorphism-validation
Open

feat: Validations for polymorphism#1630
volsa wants to merge 4 commits intomasterfrom
vosa/polymorphism-validation

Conversation

@volsa
Copy link
Member

@volsa volsa commented Mar 10, 2026

Introduces validations for polymorphism, blocked by #1629

volsa and others added 3 commits March 9, 2026 20:09
…tance (E125)

Add polymorphism-aware validation for POINTER TO assignments involving
classes and function blocks. The compiler now checks that pointee types
are related via EXTENDS, catching unrelated types, invalid downcasts,
and sibling assignments.

- Add E125 error code for incompatible polymorphic pointer assignments
- Validate both pointer-to-pointer (ptrA := ptrB) and ADR cases (ptr := ADR(instance))
- Validate call arguments passed as POINTER TO parameters
- Update E015 docs to reflect that class/FB pointers are now validated
- Add 24 tests covering valid upcasts, invalid downcasts, unrelated/sibling types,
  and call argument variants
@volsa volsa force-pushed the vosa/polymorphism-validation branch from d464617 to 52d61a2 Compare March 11, 2026 15:57
…l arguments (E126)

Add polymorphism-aware validation for interface-typed assignments and
call arguments. The compiler now checks that POU-to-interface assignments
satisfy IMPLEMENTS, and interface-to-interface assignments are valid
upcasts. These checks run during lowering (before interface types are
rewritten to __FATPOINTER) to preserve user-facing type names in errors.

- Add E126 error code for incompatible interface polymorphism
- Add validation module in dispatch lowerer with two check functions
- Validate POU-to-interface assignments (POU must implement interface)
- Validate interface-to-interface assignments (must be same or upcast)
- Validate call arguments passed as interface-typed parameters
- Surface lowerer diagnostics through PipelineParticipantMut trait
- Drop/replace invalid nodes to prevent cascading __FATPOINTER errors
- Add 26 tests covering valid upcasts, invalid downcasts, unrelated
  types, call argument variants, method existence, and field access
@volsa volsa force-pushed the vosa/polymorphism-validation branch from 52d61a2 to c1c3806 Compare March 11, 2026 16:14
@volsa volsa marked this pull request as ready for review March 11, 2026 16:17
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