-
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: adjust type cast syntax and restore old precedence (#1158)
Closes #1150 ### Summary of Changes * Type casts must now have parentheses around their type. This resolves the ambiguity between the less than operator and the start of type argument lists. * Restore their old, more intuitive precedence.
- Loading branch information
1 parent
7549fa1
commit 07623fc
Showing
18 changed files
with
60 additions
and
51 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
4 changes: 2 additions & 2 deletions
4
packages/safe-ds-lang/tests/resources/formatting/expressions/type cast.sdsdev
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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
pipeline myPipeline { | ||
1 as Int; | ||
1 as ( Int ); | ||
} | ||
|
||
// ----------------------------------------------------------------------------- | ||
|
||
pipeline myPipeline { | ||
1 as Int; | ||
1 as (Int); | ||
} |
2 changes: 1 addition & 1 deletion
2
packages/safe-ds-lang/tests/resources/generation/python/expressions/type casts/input.sdsdev
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
package tests.generation.expressions.typeCasts | ||
|
||
segment mySegment(p: Int) { | ||
val a = p as Int; | ||
val a = p as (Int); | ||
} |
2 changes: 1 addition & 1 deletion
2
...-in expression without parentheses.sdsdev → ...ts/bad-without closing parenthesis.sdsdev
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
// $TEST$ syntax_error | ||
|
||
pipeline myPipeline { | ||
1 as Int + 1; | ||
1 as (Int; | ||
} |
2 changes: 1 addition & 1 deletion
2
...safe-ds-lang/tests/resources/grammar/expressions/type casts/bad-without expression.sdsdev
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
// $TEST$ syntax_error | ||
|
||
pipeline myPipeline { | ||
as Int; | ||
as (Int); | ||
} |
5 changes: 5 additions & 0 deletions
5
...ang/tests/resources/grammar/expressions/type casts/bad-without opening parenthesis.sdsdev
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 Int); | ||
} |
5 changes: 5 additions & 0 deletions
5
...afe-ds-lang/tests/resources/grammar/expressions/type casts/bad-without parenthesis.sdsdev
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 Int; | ||
} |
2 changes: 1 addition & 1 deletion
2
packages/safe-ds-lang/tests/resources/grammar/expressions/type casts/good-basic.sdsdev
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
// $TEST$ no_syntax_error | ||
|
||
pipeline myPipeline { | ||
1 as Int; | ||
1 as (Int); | ||
} |
2 changes: 1 addition & 1 deletion
2
packages/safe-ds-lang/tests/resources/grammar/expressions/type casts/good-chained.sdsdev
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
// $TEST$ no_syntax_error | ||
|
||
pipeline myPipeline { | ||
(1 as Int) as String; | ||
1 as (Int) as (String); | ||
} |
2 changes: 1 addition & 1 deletion
2
...casts/good-in less than comparison.sdsdev → ...s than comparison with parentheses.sdsdev
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
// $TEST$ no_syntax_error | ||
|
||
pipeline myPipeline { | ||
(1 as Int) < 2; | ||
1 as (Int) < 2; | ||
} |
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