-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dfc3f45
commit 273f13d
Showing
5 changed files
with
176 additions
and
28 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
49 changes: 49 additions & 0 deletions
49
engine/baml-lib/baml/tests/validation_files/class/recursive_type_aliases.baml
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Simple alias that points to recursive type. | ||
class Node { | ||
value int | ||
next Node? | ||
} | ||
|
||
type LinkedList = Node | ||
|
||
// Mutual recursion. There is no "type" here at all. | ||
type One = Two | ||
|
||
type Two = One | ||
|
||
// Cycle. Same as above but longer. | ||
type A = B | ||
|
||
type B = C | ||
|
||
type C = A | ||
|
||
// Recursive class with alias pointing to itself. | ||
class Recursive { | ||
value int | ||
ptr RecAlias | ||
} | ||
|
||
type RecAlias = Recursive | ||
|
||
// error: Error validating: These classes form a dependency cycle: Recursive | ||
// --> class/recursive_type_aliases.baml:22 | ||
// | | ||
// 21 | // Recursive class with alias pointing to itself. | ||
// 22 | class Recursive { | ||
// 23 | value int | ||
// 24 | ptr RecAlias | ||
// 25 | } | ||
// | | ||
// error: Error validating: These aliases form a dependency cycle: One -> Two | ||
// --> class/recursive_type_aliases.baml:10 | ||
// | | ||
// 9 | // Mutual recursion. There is no "type" here at all. | ||
// 10 | type One = Two | ||
// | | ||
// error: Error validating: These aliases form a dependency cycle: A -> B -> C | ||
// --> class/recursive_type_aliases.baml:15 | ||
// | | ||
// 14 | // Cycle. Same as above but longer. | ||
// 15 | type A = B | ||
// | |
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
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
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