-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: warning if literal types or union types have duplicate entries (#…
…658) ### Summary of Changes Show a warning if a literal type or a union type has duplicate entries. --------- Co-authored-by: megalinter-bot <129584137+megalinter-bot@users.noreply.github.com>
- Loading branch information
1 parent
1775705
commit 9ba9d20
Showing
12 changed files
with
153 additions
and
25 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
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
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,29 @@ | ||
package tests.typing.types.typeArguments | ||
|
||
class MyClass<T> | ||
|
||
enum MyEnum { | ||
MyEnumVariant<T> | ||
} | ||
|
||
fun myFunction( | ||
// $TEST$ serialization Int | ||
a: MyClass<»Int«>, | ||
// $TEST$ serialization Int | ||
b: MyClass<»T = Int«>, | ||
|
||
// $TEST$ serialization String | ||
c: MyEnum.MyEnumVariant<»T = String«>, | ||
// $TEST$ serialization String | ||
d: MyEnum.MyEnumVariant<»T = String«>, | ||
|
||
// $TEST$ serialization Boolean | ||
e: unresolved<»Boolean«>, | ||
// $TEST$ serialization Boolean | ||
f: unresolved<»T = Boolean«>, | ||
|
||
// $TEST$ serialization $Unknown | ||
g: MyClass<»unresolved«>, | ||
// $TEST$ serialization $Unknown | ||
h: MyClass<»T = unresolved«>, | ||
) |
7 changes: 7 additions & 0 deletions
7
tests/resources/validation/other/types/literal types/duplicate literals/empty list.sdstest
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,7 @@ | ||
package tests.validation.other.types.literalTypes.duplicateLiterals | ||
|
||
// $TEST$ no warning r"The literal .* was already listed." | ||
|
||
segment mySegment1( | ||
p: literal<> | ||
) {} |
14 changes: 14 additions & 0 deletions
14
tests/resources/validation/other/types/literal types/duplicate literals/main.sdstest
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,14 @@ | ||
package tests.validation.other.types.literalTypes.duplicateLiterals | ||
|
||
segment mySegment( | ||
// $TEST$ no warning r"The literal .* was already listed." | ||
p: literal<»1«>, | ||
q: literal< | ||
// $TEST$ no warning r"The literal .* was already listed." | ||
»1«, | ||
// $TEST$ no warning r"The literal .* was already listed." | ||
»2«, | ||
// $TEST$ warning r"The literal 1 was already listed." | ||
»1«, | ||
>, | ||
) {} |
7 changes: 7 additions & 0 deletions
7
tests/resources/validation/other/types/union types/duplicate types/empty list.sdstest
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,7 @@ | ||
package tests.validation.other.types.unionTypes.duplicateTypes | ||
|
||
// $TEST$ no warning r"The type .* was already listed." | ||
|
||
segment mySegment1( | ||
p: union<> | ||
) {} |
14 changes: 14 additions & 0 deletions
14
tests/resources/validation/other/types/union types/duplicate types/main.sdstest
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,14 @@ | ||
package tests.validation.other.types.unionTypes.duplicateTypes | ||
|
||
segment mySegment( | ||
// $TEST$ no warning r"The type .* was already listed." | ||
p: union<»Int«>, | ||
q: union< | ||
// $TEST$ no warning r"The type .* was already listed." | ||
»Int«, | ||
// $TEST$ no warning r"The type .* was already listed." | ||
»String«, | ||
// $TEST$ warning r"The type 'Int' was already listed." | ||
»Int«, | ||
>, | ||
) {} |
16 changes: 0 additions & 16 deletions
16
tests/resources/validation/other/types/union types/must have type arguments/main.sdstest
This file was deleted.
Oops, something went wrong.
16 changes: 16 additions & 0 deletions
16
tests/resources/validation/other/types/union types/must have types/main.sdstest
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,16 @@ | ||
package tests.validation.other.types.unionTypes.mustHaveTypes | ||
|
||
// $TEST$ error "A union type must have at least one type." | ||
segment mySegment1( | ||
p: union»<>« | ||
) {} | ||
|
||
// $TEST$ no error "A union type must have at least one type." | ||
segment mySegment2( | ||
p: union»<Int>« | ||
) {} | ||
|
||
// $TEST$ no error "A union type must have at least one type." | ||
segment mySegment3( | ||
p: union»<Int, Float>« | ||
) {} |