Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a LocalScope for CollectionComprehensions and generate a Declaration #2019

Merged
merged 57 commits into from
Feb 11, 2025
Merged
Changes from 1 commit
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
3387229
Create scope for collection comprehensions
KuechA Jan 31, 2025
209c218
generate local variables in python add declarations pass for comprehe…
KuechA Jan 31, 2025
1ff35b8
Extend test to check fixes
KuechA Jan 31, 2025
501d597
Remove useless flag
KuechA Jan 31, 2025
cb0b660
Add test case
KuechA Jan 31, 2025
8b8fccd
Adapt test
KuechA Jan 31, 2025
c7893a6
Test resolution of param
KuechA Jan 31, 2025
110c288
Reduce c&p code
KuechA Jan 31, 2025
8011422
add documentation
KuechA Jan 31, 2025
9489ecf
Move applyWithScope to Node
KuechA Jan 31, 2025
091041a
python style
KuechA Jan 31, 2025
d75f3f3
Merge branch 'main' into ak/python-comprehension-scope
KuechA Jan 31, 2025
4a53e41
more tests: binding
maximiliankaul Feb 5, 2025
2c17051
Merge branch 'main' into ak/python-comprehension-scope
KuechA Feb 5, 2025
b6e7546
Enter scope only for python3
KuechA Feb 5, 2025
485fc73
numbers to text
KuechA Feb 5, 2025
a0ff2fb
Test for python2 behavior
KuechA Feb 5, 2025
5dabf21
Document test
KuechA Feb 5, 2025
2408e3f
Leave and re-enter scopes of comprehensions for assign expressions in…
KuechA Feb 5, 2025
e24819f
Add test for nested comprehensions with := assignment
KuechA Feb 5, 2025
b6e386f
Higher code coverage in test
KuechA Feb 5, 2025
e98d6b8
Test version info
KuechA Feb 5, 2025
3529bbb
Extract collection comprehension tests to own file
KuechA Feb 6, 2025
deab3da
Rename
KuechA Feb 6, 2025
43c1400
Document test
KuechA Feb 6, 2025
7cca036
Document more asserts and rename wrong variable names
KuechA Feb 6, 2025
97975a3
Document CollectionComprehensionPython3Test.testDictComprehensions
KuechA Feb 6, 2025
96ddeab
Document CollectionComprehensionPython3Test.testSetComprehensions
KuechA Feb 6, 2025
166a638
Document CollectionComprehensionPython3Test.testListComprehensions
KuechA Feb 6, 2025
74f0aa9
Fix error in CollectionComprehensionPython3Test.testListComprehensions
KuechA Feb 6, 2025
86b36cc
Fix style of CollectionComprehensionPython2Test.testComprehensionExpr…
KuechA Feb 6, 2025
0d383fc
Fix tests
KuechA Feb 6, 2025
3b37c2a
Test improvements
KuechA Feb 6, 2025
92ddb45
Remove python2 test
KuechA Feb 6, 2025
e55f209
Remove version-based logic which is no longer required
KuechA Feb 6, 2025
ddc7ed2
Merge branch 'main' into ak/python-comprehension-scope
KuechA Feb 6, 2025
cdb92e8
no more typos
KuechA Feb 6, 2025
4908a5e
object type to primitive type for consistency with other frontends an…
KuechA Feb 6, 2025
2482db0
versionInfo as extension variable
oxisto Feb 6, 2025
10a1603
Merge branch 'main' into ak/python-comprehension-scope
KuechA Feb 7, 2025
b4eb266
Revert changes to VersionInfo
KuechA Feb 7, 2025
7de93e2
Merge branch 'main' into ak/python-comprehension-scope
KuechA Feb 7, 2025
31f7377
Add test for write to list index
KuechA Feb 7, 2025
68dc283
Add another test
KuechA Feb 7, 2025
5c9a6af
Add another test: reversed order in tuple
KuechA Feb 7, 2025
4863da8
fix documentation
KuechA Feb 7, 2025
f521517
Another test
KuechA Feb 7, 2025
cb272ae
Merge branch 'main' into ak/python-comprehension-scope
KuechA Feb 7, 2025
edc3170
Another test for more code coverage
KuechA Feb 7, 2025
8707109
Test applyWithScope without ctx
KuechA Feb 7, 2025
af9184e
Fix test and typos
KuechA Feb 7, 2025
1ebbc6f
Another assertion
KuechA Feb 7, 2025
20351d3
Add more strict assumptions again
KuechA Feb 7, 2025
d4bcd26
Add another test for fields
KuechA Feb 7, 2025
201f026
Comment out failing asserts
KuechA Feb 11, 2025
859cd7f
Merge branch 'main' into ak/python-comprehension-scope
KuechA Feb 11, 2025
0bbb301
Fix test
KuechA Feb 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove useless flag
  • Loading branch information
KuechA committed Jan 31, 2025
commit 501d597482dc98ff9109d2b307d5fad58c9a4350
Original file line number Diff line number Diff line change
@@ -199,26 +199,19 @@
* Generates a new [VariableDeclaration] for [Reference] (and those included in a
* [InitializerListExpression]) in the [ComprehensionExpression.variable].
*/
private fun handleComprehensionExpression(
comprehensionExpression: ComprehensionExpression,
setAccessValue: Boolean = false,
) {
private fun handleComprehensionExpression(comprehensionExpression: ComprehensionExpression) {
when (val variable = comprehensionExpression.variable) {
is Reference -> {
if (setAccessValue) {
variable.access = AccessValues.WRITE
}
variable.access = AccessValues.WRITE
handleWriteToReference(variable)
}
is InitializerListExpression -> {
variable.initializers.forEach {

Check warning on line 209 in cpg-language-python/src/main/kotlin/de/fraunhofer/aisec/cpg/passes/PythonAddDeclarationsPass.kt

Codecov / codecov/patch

cpg-language-python/src/main/kotlin/de/fraunhofer/aisec/cpg/passes/PythonAddDeclarationsPass.kt#L209

Added line #L209 was not covered by tests
(it as? Reference)?.let { ref ->
if (setAccessValue) {
ref.access = AccessValues.WRITE
}
ref.access = AccessValues.WRITE
handleWriteToReference(ref)
}
}

Check warning on line 214 in cpg-language-python/src/main/kotlin/de/fraunhofer/aisec/cpg/passes/PythonAddDeclarationsPass.kt

Codecov / codecov/patch

cpg-language-python/src/main/kotlin/de/fraunhofer/aisec/cpg/passes/PythonAddDeclarationsPass.kt#L211-L214

Added lines #L211 - L214 were not covered by tests
}
}
}
Loading