-
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.
fix: generation of extra statements for parameters of expression lamb…
…das (#1137) Closes #1136 ### Summary of Changes Extra statements that were generated for the expression of an expression lambda were incorrectly placed outside the lambda. This broke the code generation for parameters of expression lambdas that were used as receivers of method calls (see the linked issue).
- Loading branch information
1 parent
7b8ae60
commit 4add401
Showing
9 changed files
with
118 additions
and
2 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
26 changes: 26 additions & 0 deletions
26
...ock lambdas/generated/tests/generation/python/runnerIntegration/blockLambdas/gen_input.py
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,26 @@ | ||
# Imports ---------------------------------------------------------------------- | ||
|
||
import safeds_runner | ||
from tests.generation.python.runnerIntegration.blockLambdas import f | ||
|
||
# Pipelines -------------------------------------------------------------------- | ||
|
||
def myPipeline(): | ||
def __gen_lambda_1(p): | ||
__gen_receiver_0 = p | ||
__gen_block_lambda_result_r = safeds_runner.memoized_dynamic_call( | ||
__gen_receiver_0, | ||
"g", | ||
[], | ||
{}, | ||
[] | ||
) | ||
return __gen_block_lambda_result_r | ||
__gen_result = safeds_runner.memoized_static_call( | ||
"tests.generation.python.runnerIntegration.blockLambdas.f", | ||
f, | ||
[__gen_lambda_1], | ||
{}, | ||
[] | ||
) | ||
safeds_runner.save_placeholder('result', __gen_result) |
1 change: 1 addition & 0 deletions
1
...lambdas/generated/tests/generation/python/runnerIntegration/blockLambdas/gen_input.py.map
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
4 changes: 4 additions & 0 deletions
4
.../generated/tests/generation/python/runnerIntegration/blockLambdas/gen_input_myPipeline.py
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 @@ | ||
from .gen_input import myPipeline | ||
|
||
if __name__ == '__main__': | ||
myPipeline() |
21 changes: 21 additions & 0 deletions
21
...sts/resources/generation/python/runner integration/expressions/block lambdas/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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Related to https://github.com/Safe-DS/DSL/issues/1136 | ||
|
||
package tests.generation.python.runnerIntegration.blockLambdas | ||
|
||
class MyClass { | ||
@Pure | ||
fun g() -> r: Int | ||
} | ||
|
||
@Pure | ||
fun f( | ||
callback: (p: MyClass) -> (r: Int) | ||
) -> result: Any | ||
|
||
pipeline myPipeline { | ||
val result = f( | ||
(p) { | ||
yield r = p.g(); | ||
} | ||
); | ||
} |
25 changes: 25 additions & 0 deletions
25
...ambdas/generated/tests/generation/python/runnerIntegration/expressionLambdas/gen_input.py
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,25 @@ | ||
# Imports ---------------------------------------------------------------------- | ||
|
||
import safeds_runner | ||
from tests.generation.python.runnerIntegration.expressionLambdas import f | ||
|
||
# Pipelines -------------------------------------------------------------------- | ||
|
||
def myPipeline(): | ||
def __gen_lambda_0(p): | ||
__gen_receiver_1 = p | ||
return safeds_runner.memoized_dynamic_call( | ||
__gen_receiver_1, | ||
"g", | ||
[], | ||
{}, | ||
[] | ||
) | ||
__gen_result = safeds_runner.memoized_static_call( | ||
"tests.generation.python.runnerIntegration.expressionLambdas.f", | ||
f, | ||
[__gen_lambda_0], | ||
{}, | ||
[] | ||
) | ||
safeds_runner.save_placeholder('result', __gen_result) |
1 change: 1 addition & 0 deletions
1
...as/generated/tests/generation/python/runnerIntegration/expressionLambdas/gen_input.py.map
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
4 changes: 4 additions & 0 deletions
4
...rated/tests/generation/python/runnerIntegration/expressionLambdas/gen_input_myPipeline.py
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 @@ | ||
from .gen_input import myPipeline | ||
|
||
if __name__ == '__main__': | ||
myPipeline() |
19 changes: 19 additions & 0 deletions
19
...esources/generation/python/runner integration/expressions/expression lambdas/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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Related to https://github.com/Safe-DS/DSL/issues/1136 | ||
|
||
package tests.generation.python.runnerIntegration.expressionLambdas | ||
|
||
class MyClass { | ||
@Pure | ||
fun g() -> r: Int | ||
} | ||
|
||
@Pure | ||
fun f( | ||
callback: (p: MyClass) -> (r: Int) | ||
) -> result: Any | ||
|
||
pipeline myPipeline { | ||
val result = f( | ||
(p) -> p.g() | ||
); | ||
} |