-
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.
Closes #835 ### Summary of Changes In some cases, e.g. when no runner is installed to infer the initial schema of a dataset, we may not be able to infer the type of an expression. This PR adds type casts to specify the type manually in this case.
- Loading branch information
1 parent
b35566d
commit 66c3666
Showing
20 changed files
with
161 additions
and
3 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
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
9 changes: 9 additions & 0 deletions
9
packages/safe-ds-lang/tests/resources/formatting/expressions/elvis operator.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,9 @@ | ||
pipeline myPipeline { | ||
1 ?: 2; | ||
} | ||
|
||
// ----------------------------------------------------------------------------- | ||
|
||
pipeline myPipeline { | ||
1 ?: 2; | ||
} |
9 changes: 9 additions & 0 deletions
9
packages/safe-ds-lang/tests/resources/formatting/expressions/type cast.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,9 @@ | ||
pipeline myPipeline { | ||
1 as Int; | ||
} | ||
|
||
// ----------------------------------------------------------------------------- | ||
|
||
pipeline myPipeline { | ||
1 as Int; | ||
} |
5 changes: 5 additions & 0 deletions
5
...lang/tests/resources/grammar/expressions/elvis operators/bad-without left operand.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,5 @@ | ||
// $TEST$ syntax_error | ||
|
||
pipeline myPipeline { | ||
?: Int; | ||
} |
5 changes: 5 additions & 0 deletions
5
...ang/tests/resources/grammar/expressions/elvis operators/bad-without right operand.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,5 @@ | ||
// $TEST$ syntax_error | ||
|
||
pipeline myPipeline { | ||
1 ?:; | ||
} |
5 changes: 5 additions & 0 deletions
5
packages/safe-ds-lang/tests/resources/grammar/expressions/elvis operators/good-basic.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,5 @@ | ||
// $TEST$ no_syntax_error | ||
|
||
pipeline myPipeline { | ||
null ?: 1; | ||
} |
5 changes: 5 additions & 0 deletions
5
...ges/safe-ds-lang/tests/resources/grammar/expressions/elvis operators/good-chained.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,5 @@ | ||
// $TEST$ no_syntax_error | ||
|
||
pipeline myPipeline { | ||
null ?: null ?: 1; | ||
} |
5 changes: 5 additions & 0 deletions
5
...afe-ds-lang/tests/resources/grammar/expressions/type casts/bad-without expression.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,5 @@ | ||
// $TEST$ syntax_error | ||
|
||
pipeline myPipeline { | ||
as Int; | ||
} |
5 changes: 5 additions & 0 deletions
5
...ages/safe-ds-lang/tests/resources/grammar/expressions/type casts/bad-without type.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,5 @@ | ||
// $TEST$ syntax_error | ||
|
||
pipeline myPipeline { | ||
1 as; | ||
} |
5 changes: 5 additions & 0 deletions
5
packages/safe-ds-lang/tests/resources/grammar/expressions/type casts/good-basic.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,5 @@ | ||
// $TEST$ no_syntax_error | ||
|
||
pipeline myPipeline { | ||
1 as Int; | ||
} |
5 changes: 5 additions & 0 deletions
5
packages/safe-ds-lang/tests/resources/grammar/expressions/type casts/good-chained.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,5 @@ | ||
// $TEST$ no_syntax_error | ||
|
||
pipeline myPipeline { | ||
1 as Int as String; | ||
} |
9 changes: 9 additions & 0 deletions
9
...s/safe-ds-lang/tests/resources/partial evaluation/recursive cases/type casts/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,9 @@ | ||
package tests.partialValidation.recursiveCases.typeCasts | ||
|
||
pipeline test { | ||
// $TEST$ serialization true | ||
»true as Boolean«; | ||
|
||
// $TEST$ serialization 1 | ||
»1 as Boolean«; | ||
} |
14 changes: 14 additions & 0 deletions
14
packages/safe-ds-lang/tests/resources/typing/expressions/type casts/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.typing.expressions.typeCasts | ||
|
||
@Pure fun f() -> r: Int | ||
|
||
pipeline myPipeline { | ||
// $TEST$ serialization Boolean | ||
»1 as Boolean«; // Partial evaluator can handle expression | ||
|
||
// $TEST$ serialization Boolean | ||
»r as Boolean«; // Partial evaluator cannot handle expression | ||
|
||
// $TEST$ serialization Boolean | ||
»unresolved as Boolean«; // Expression has unknown type | ||
} |
9 changes: 9 additions & 0 deletions
9
packages/safe-ds-lang/tests/resources/validation/types/checking/type casts/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,9 @@ | ||
package tests.validation.types.checking.typeCasts | ||
|
||
pipeline test { | ||
// $TEST$ no error "Type casts can only be applied to expressions of unknown type." | ||
»unresolved« as Int; | ||
|
||
// $TEST$ error "Type casts can only be applied to expressions of unknown type." | ||
»1« as Int; | ||
} |