-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow structural recursion in type aliases (#1207)
Allow structural recursion (like TS): ```baml type RecursiveMap = map<string, RecursiveMap> type A = A[] ``` Follow up on #1163 <!-- ELLIPSIS_HIDDEN --> ---- > [!IMPORTANT] > Enable structural recursion in type aliases by updating cycle validation logic, adding tests, and supporting recursive type aliases in Python, Ruby, and TypeScript clients. > > - **Behavior**: > - Allow structural recursion for type alias cycles involving maps and lists in `cycle.rs`. > - Update `validate()` in `cycle.rs` to handle structural recursion and report cycles. > - Modify `ParserDatabase::finalize_dependencies()` in `lib.rs` to resolve type aliases and handle cycles. > - **Functions**: > - Add `insert_required_alias_deps()` in `cycle.rs` to handle alias dependencies. > - Rename `insert_required_deps()` to `insert_required_class_deps()` in `cycle.rs`. > - **Models**: > - Add `structural_recursive_alias_cycles` to `Types` in `mod.rs`. > - **Tests**: > - Update `recursive_type_aliases.baml` to reflect new cycle validation behavior. > - Add tests in `lib.rs` to verify structural recursion handling. > - **Language Support**: > - Update Python, Ruby, and TypeScript clients to handle recursive type aliases. > - **Misc**: > - Add `is_subtype()` to `IRHelper` in `mod.rs` to support subtyping checks. > - Add `coerce_alias()` in `coerce_alias.rs` to handle alias coercion. > - Add integration tests for recursive alias cycles in `integ-tests/typescript/tests/integ-tests.test.ts`. > > <sup>This description was created by </sup>[<img alt="Ellipsis" src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=BoundaryML%2Fbaml&utm_source=github&utm_medium=referral)<sup> for fc25050. It will automatically update as commits are pushed.</sup> <!-- ELLIPSIS_HIDDEN -->
- Loading branch information
1 parent
3d95e20
commit 4eb543a
Showing
48 changed files
with
2,484 additions
and
329 deletions.
There are no files selected for viewing
This file contains 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
Oops, something went wrong.