-
Notifications
You must be signed in to change notification settings - Fork 218
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #1247
- Loading branch information
Showing
8 changed files
with
149 additions
and
30 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
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
4 changes: 4 additions & 0 deletions
4
...resources/software/amazon/smithy/model/errorfiles/validators/shape-recursion-union.errors
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,4 @@ | ||
[ERROR] smithy.example#RecursiveUnionA: It is impossible to create instances of this recursive union | ShapeRecursion | ||
[ERROR] smithy.example#RecursiveUnionB: It is impossible to create instances of this recursive union | ShapeRecursion | ||
[ERROR] smithy.example#RecursiveUnion: It is impossible to create instances of this recursive union | ShapeRecursion | ||
[ERROR] smithy.example#RecursiveNext: It is impossible to create instances of this recursive union | ShapeRecursion |
67 changes: 67 additions & 0 deletions
67
...resources/software/amazon/smithy/model/errorfiles/validators/shape-recursion-union.smithy
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,67 @@ | ||
$version: "1.0" | ||
|
||
namespace smithy.example | ||
|
||
// This is impossible because there is no non-recursive branch along | ||
// the recursive path back to itself. | ||
union RecursiveUnionA { | ||
b: RecursiveUnionB | ||
} | ||
|
||
union RecursiveUnionB { | ||
a: RecursiveUnionA | ||
} | ||
|
||
// These unions are fine because there is a non-recursive branch along the | ||
// recursive path back to itself: | ||
// 1. {"e": {"str": "hi"}} | ||
// 2. {"d": {"c": {"e": {"str": "hi"}}}} | ||
union RecursiveUnionC { | ||
d: RecursiveUnionD, | ||
e: OkUnion | ||
} | ||
|
||
union RecursiveUnionD { | ||
c: RecursiveUnionC | ||
} | ||
|
||
union OkUnion { | ||
str: String | ||
} | ||
|
||
// This is fine too because on the of the recursive branches contains a list | ||
// which gives the type a size. | ||
union RecursiveUnionE { | ||
f: RecursiveUnionF | ||
} | ||
|
||
union RecursiveUnionF { | ||
e: EList | ||
} | ||
|
||
list EList { | ||
member: RecursiveUnionE | ||
} | ||
|
||
// It's impossible to provide a value for this union. | ||
union RecursiveUnion { | ||
a: RecursiveUnion, | ||
b: RecursiveUnion, | ||
} | ||
|
||
union NotFullyRecursiveUnion { | ||
a: RecursiveUnion, | ||
b: RecursiveUnion, | ||
c: String | ||
} | ||
|
||
// This structure is invalid and the union is invalid | ||
structure Start { | ||
@required | ||
foo: RecursiveNext | ||
} | ||
|
||
union RecursiveNext { | ||
a: Start, | ||
b: Start | ||
} |
1 change: 0 additions & 1 deletion
1
...s/software/amazon/smithy/model/errorfiles/validators/union-cant-be-fully-recursive.errors
This file was deleted.
Oops, something went wrong.
15 changes: 0 additions & 15 deletions
15
...s/software/amazon/smithy/model/errorfiles/validators/union-cant-be-fully-recursive.smithy
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ union A { | |
} | ||
|
||
union B { | ||
a: A | ||
str: String | ||
} | ||
|
||
union C | ||
|