-
-
Notifications
You must be signed in to change notification settings - Fork 377
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix expression conversion * Extract duplicate code into a separate helper method * improve conversion strategy * Add .sk to test file * Simplify conversion usage We need to use conversion whenever there are multiple return types. If the expression does not accept our supertype, then we can attempt to convert it, which will already handle safety checks for multiple return types * SimpleExpression: fix possible return type conversion This fixes SimpleExpression not converting possible return types that are not contained in the desired types array. For example, if an expression can return a Number or a String, and we want an Expression that is a Number or an World, it will now include converters for String->Number and String->World * Use safety checks of ConvertedExpression * Remove incorrect converter remake * Move logic from SimpleExpression to ConvertedExpression --------- Co-authored-by: APickledWalrus <[email protected]> Co-authored-by: Efnilite <[email protected]> Co-authored-by: Moderocky <[email protected]>
- Loading branch information
1 parent
3c94063
commit cca446d
Showing
4 changed files
with
42 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
13 changes: 13 additions & 0 deletions
13
src/test/skript/tests/regressions/7164-expressions sometimes dont convert.sk
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,13 @@ | ||
test "expressions sometimes dont convert": | ||
assert formatted ({_foo} + {_bar}) is not set with "formatting nothing shouldn't throw an error" | ||
|
||
set {_foo} to "test" | ||
assert formatted ({_foo} + {_bar}) is not set with "formatting string + none shouldn't throw an error" | ||
|
||
set {_foo} to 1 | ||
set {_bar} to 2 | ||
assert formatted ({_foo} + {_bar}) is not set with "formatting number + number shouldn't throw an error" | ||
|
||
set {_foo} to "foo" | ||
set {_bar} to "bar" | ||
assert formatted ({_foo} + {_bar}) is "foobar" with "formatting strings doesn't work" |