-
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: handling of default values in entry point of call graph computat…
…ion (#797) ### Summary of Changes Consider the following code: ``` @pure fun default() -> r: Any segment mySegment(param: () -> () = default) { »param()«; } ``` When computing the call graph for the `param()` call, we were previously always substituting `param` with its default value, since the parameter substitutions were empty in the entry point. Because of this, we were incorrectly considering the `param()` call as pure, just like the segment `mySegment`.
- Loading branch information
1 parent
5017759
commit a5db23c
Showing
8 changed files
with
112 additions
and
12 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
13 changes: 13 additions & 0 deletions
13
...ang/tests/resources/call graph/block lambda call/default value/previous parameter.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,13 @@ | ||
package tests.callGraph.blockLambdaCall.defaultValue.previousParameter | ||
|
||
@Pure fun default() -> result: Any | ||
|
||
pipeline myPipeline { | ||
val lambda = ( | ||
f: () -> (result: Any) = default, | ||
g: Any = f() | ||
) {}; | ||
|
||
// $TEST$ ["$blockLambda", "default"] | ||
»lambda()«; | ||
} |
13 changes: 13 additions & 0 deletions
13
...fe-ds-lang/tests/resources/call graph/class call/default value/previous parameter.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,13 @@ | ||
package tests.callGraph.classCall.defaultValue.previousParameter | ||
|
||
@Pure fun default() -> result: Any | ||
|
||
class MyClass( | ||
f: () -> (result: Any) = default, | ||
g: Any = f() | ||
) | ||
|
||
pipeline myPipeline { | ||
// $TEST$ ["MyClass", "default", "default"] | ||
»MyClass()«; | ||
} |
12 changes: 12 additions & 0 deletions
12
...ges/safe-ds-lang/tests/resources/call graph/default value handling in entry point.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,12 @@ | ||
package tests.callGraph.defaultValueHandlingInEntryPoint | ||
|
||
/* | ||
* We must **not** assume that the default value is used just because no substitution is given for a parameter. | ||
*/ | ||
|
||
@Pure fun default() -> r: Any | ||
|
||
segment mySegment(param: () -> () = default) { | ||
// $TEST$ ["param"] | ||
»param()«; | ||
} |
15 changes: 15 additions & 0 deletions
15
...ang/tests/resources/call graph/enum variant call/default value/previous parameter.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,15 @@ | ||
package tests.callGraph.enumVariantCall.defaultValue.previousParameter | ||
|
||
@Pure fun default() -> result: Any | ||
|
||
enum MyEnum { | ||
MyVariant( | ||
f: () -> (result: Any) = default, | ||
g: Any = f() | ||
) | ||
} | ||
|
||
pipeline myPipeline { | ||
// $TEST$ ["MyVariant", "default", "default"] | ||
»MyEnum.MyVariant()«; | ||
} |
13 changes: 13 additions & 0 deletions
13
...ests/resources/call graph/expression lambda call/default value/previous parameter.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,13 @@ | ||
package tests.callGraph.expressionLambdaCall.defaultValue.previousParameter | ||
|
||
@Pure fun default() -> result: Any | ||
|
||
pipeline myPipeline { | ||
val lambda = ( | ||
f: () -> (result: Any) = default, | ||
g: Any = f() | ||
) -> 1; | ||
|
||
// $TEST$ ["$expressionLambda", "default"] | ||
»lambda()«; | ||
} |
13 changes: 13 additions & 0 deletions
13
...ds-lang/tests/resources/call graph/function call/default value/previous parameter.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,13 @@ | ||
package tests.callGraph.functionCall.defaultValue.previousParameter | ||
|
||
@Pure fun default() -> result: Any | ||
|
||
@Pure fun myFunction( | ||
f: () -> (result: Any) = default, | ||
g: Any = f() | ||
) | ||
|
||
pipeline myPipeline { | ||
// $TEST$ ["myFunction", "default", "default"] | ||
»myFunction()«; | ||
} |
13 changes: 13 additions & 0 deletions
13
...-ds-lang/tests/resources/call graph/segment call/default value/previous parameter.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,13 @@ | ||
package tests.callGraph.segmentCall.defaultValue.previousParameter | ||
|
||
@Pure fun default() -> result: Any | ||
|
||
segment mySegment( | ||
f: () -> (result: Any) = default, | ||
g: Any = f() | ||
) {} | ||
|
||
pipeline myPipeline { | ||
// $TEST$ ["mySegment", "default"] | ||
»mySegment()«; | ||
} |