-
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: invalid Python code generated for constructor calls (#981)
Closes #980 ### Summary of Changes No longer add an empty receiver parameter to the code that is generated for constructor calls.
- Loading branch information
1 parent
b59d6f0
commit c7d006f
Showing
10 changed files
with
84 additions
and
60 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
57 changes: 0 additions & 57 deletions
57
...gration/expressions/call/generated/tests/generator/callWithRunnerIntegration/gen_input.py
This file was deleted.
Oops, something went wrong.
57 changes: 57 additions & 0 deletions
57
...alls/main/generated/tests/generator/runnerIntegration/expressions/calls/main/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,57 @@ | ||
# Imports ---------------------------------------------------------------------- | ||
|
||
import safeds_runner | ||
from typing import Any, Callable, TypeVar | ||
|
||
# Type variables --------------------------------------------------------------- | ||
|
||
__gen_T = TypeVar("__gen_T") | ||
|
||
# Utils ------------------------------------------------------------------------ | ||
|
||
def __gen_null_safe_call(receiver: Any, callable: Callable[[], __gen_T]) -> __gen_T | None: | ||
return callable() if receiver is not None else None | ||
|
||
# Segments --------------------------------------------------------------------- | ||
|
||
def segment_a(a): | ||
__gen_yield_result = (a) * (2) | ||
return __gen_yield_result | ||
|
||
# Pipelines -------------------------------------------------------------------- | ||
|
||
def test(): | ||
f(safeds_runner.memoized_call("tests.generator.runnerIntegration.expressions.calls.main.g", lambda *_ : g(1, param2=2), [1, 2], [])) | ||
f(safeds_runner.memoized_call("tests.generator.runnerIntegration.expressions.calls.main.g", lambda *_ : g(2, param2=1), [2, 1], [])) | ||
f(safeds_runner.memoized_call("tests.generator.runnerIntegration.expressions.calls.main.h", lambda *_ : h(1, param_2=2), [1, 2], [])) | ||
f(safeds_runner.memoized_call("tests.generator.runnerIntegration.expressions.calls.main.h", lambda *_ : h(2, param_2=1), [2, 1], [])) | ||
f(safeds_runner.memoized_call("tests.generator.runnerIntegration.expressions.calls.main.h", h, [2, 0], [])) | ||
'abc'.i() | ||
'abc'.j(123) | ||
k(456, 1.23) | ||
__gen_null_safe_call(f, lambda: f(safeds_runner.memoized_call("tests.generator.runnerIntegration.expressions.calls.main.g", lambda *_ : g(1, param2=2), [1, 2], []))) | ||
__gen_null_safe_call(f, lambda: f(safeds_runner.memoized_call("tests.generator.runnerIntegration.expressions.calls.main.g", lambda *_ : g(2, param2=1), [2, 1], []))) | ||
__gen_null_safe_call(f, lambda: f(safeds_runner.memoized_call("tests.generator.runnerIntegration.expressions.calls.main.h", lambda *_ : h(1, param_2=2), [1, 2], []))) | ||
__gen_null_safe_call(f, lambda: f(safeds_runner.memoized_call("tests.generator.runnerIntegration.expressions.calls.main.h", lambda *_ : h(2, param_2=1), [2, 1], []))) | ||
__gen_null_safe_call(f, lambda: f(safeds_runner.memoized_call("tests.generator.runnerIntegration.expressions.calls.main.h", h, [2, 0], []))) | ||
__gen_null_safe_call(i, lambda: 'abc'.i()) | ||
__gen_null_safe_call(j, lambda: 'abc'.j(123)) | ||
__gen_null_safe_call(k, lambda: k(456, 1.23)) | ||
f(safeds_runner.memoized_call("tests.generator.runnerIntegration.expressions.calls.main.readFile", readFile, [], [safeds_runner.file_mtime('a.txt')])) | ||
f(l(lambda a: segment_a(a))) | ||
f(l(lambda a: (3) * (segment_a(a)))) | ||
f(l(lambda a: safeds_runner.memoized_call("tests.generator.runnerIntegration.expressions.calls.main.m", m, [(3) * (segment_a(a))], []))) | ||
f(l(lambda a: (3) * (safeds_runner.memoized_call("tests.generator.runnerIntegration.expressions.calls.main.m", m, [safeds_runner.memoized_call("tests.generator.runnerIntegration.expressions.calls.main.m", m, [(3) * (segment_a(a))], [])], [])))) | ||
def __gen_block_lambda_0(a): | ||
__gen_block_lambda_result_result = segment_a(a) | ||
return __gen_block_lambda_result_result | ||
f(l(__gen_block_lambda_0)) | ||
def __gen_block_lambda_1(a): | ||
__gen_block_lambda_result_result = safeds_runner.memoized_call("tests.generator.runnerIntegration.expressions.calls.main.m", m, [segment_a(a)], []) | ||
return __gen_block_lambda_result_result | ||
f(l(__gen_block_lambda_1)) | ||
f(safeds_runner.memoized_call("tests.generator.runnerIntegration.expressions.calls.main.l", l, [lambda a: (3) * (a)], [])) | ||
def __gen_block_lambda_2(a): | ||
__gen_block_lambda_result_result = (3) * (safeds_runner.memoized_call("tests.generator.runnerIntegration.expressions.calls.main.m", m, [a], [])) | ||
return __gen_block_lambda_result_result | ||
f(safeds_runner.memoized_call("tests.generator.runnerIntegration.expressions.calls.main.l", l, [__gen_block_lambda_2], [])) |
2 changes: 1 addition & 1 deletion
2
...allWithRunnerIntegration/gen_input.py.map → ...n/expressions/calls/main/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.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...ntegration/expressions/call/input.sdstest → ...tion/expressions/calls/main/input.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
9 changes: 9 additions & 0 deletions
9
...sses/generated/tests/generator/runnerIntegration/expressions/calls/ofClasses/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,9 @@ | ||
# Imports ---------------------------------------------------------------------- | ||
|
||
import safeds_runner | ||
|
||
# Pipelines -------------------------------------------------------------------- | ||
|
||
def test(): | ||
a = safeds_runner.memoized_call("tests.generator.runnerIntegration.expressions.calls.ofClasses.MyClass", MyClass, [0], []) | ||
safeds_runner.save_placeholder('a', a) |
1 change: 1 addition & 0 deletions
1
.../generated/tests/generator/runnerIntegration/expressions/calls/ofClasses/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/generator/runnerIntegration/expressions/calls/ofClasses/gen_input_test.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 test | ||
|
||
if __name__ == '__main__': | ||
test() |
9 changes: 9 additions & 0 deletions
9
...resources/generation/python/runner integration/expressions/calls/of classes/input.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 @@ | ||
// Related to https://github.com/Safe-DS/DSL/issues/980 | ||
|
||
package tests.generator.runnerIntegration.expressions.calls.ofClasses | ||
|
||
class MyClass(p: Int) | ||
|
||
pipeline test { | ||
val a = MyClass(0); | ||
} |