Skip to content

Fix: intersect() drops Validated types when merging interface with extends#2451

Open
nickpokhilko wants to merge 1 commit into
encoredev:mainfrom
nickpokhilko:fix/intersect-validated-extends
Open

Fix: intersect() drops Validated types when merging interface with extends#2451
nickpokhilko wants to merge 1 commit into
encoredev:mainfrom
nickpokhilko:fix/intersect-validated-extends

Conversation

@nickpokhilko

Copy link
Copy Markdown

What

Add (Validated, Validated), (Validated, _) and (_, Validated) arms to intersect() in tsparser/src/parser/types/typ.rs.

Why

When resolving interface Derived extends Base, fields present in both interfaces with validators in the derived type (e.g. string & MinLen<1>) fell through all existing patterns to the catch-all (_, _) => Type::Basic(Basic::Never), silently erasing the field from the parsed schema.

Root cause path:

  1. do_interface_decl intersects the derived interface body with each base type via intersect(derived, base)
  2. For a field present in both, the derived field type is Validated { typ: Basic(String), expr: MinLen∧MaxLen } and the base is Basic(String)
  3. intersect(Validated{…}, Basic(String)) matched none of the existing Validation/Validated arms (which only handle Validation — the unapplied expression type, not Validated — the already-applied wrapper)
  4. Fell through to (_, _) => Type::Basic(Basic::Never)

Verification

Added tests/testdata/interface_extends_validation.txt covering:

  • Single extends with MinLen/MaxLen validators on an inherited field
  • Two levels of extends with optional validated fields

cargo test -p encore-tsparser test_parser passes.

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