diff --git a/cpg-language-python/src/main/kotlin/de/fraunhofer/aisec/cpg/frontends/python/PythonLanguage.kt b/cpg-language-python/src/main/kotlin/de/fraunhofer/aisec/cpg/frontends/python/PythonLanguage.kt index 49fd56726f..a0526f0255 100644 --- a/cpg-language-python/src/main/kotlin/de/fraunhofer/aisec/cpg/frontends/python/PythonLanguage.kt +++ b/cpg-language-python/src/main/kotlin/de/fraunhofer/aisec/cpg/frontends/python/PythonLanguage.kt @@ -31,6 +31,7 @@ import de.fraunhofer.aisec.cpg.graph.autoType import de.fraunhofer.aisec.cpg.graph.declarations.ParameterDeclaration import de.fraunhofer.aisec.cpg.graph.scopes.Symbol import de.fraunhofer.aisec.cpg.graph.statements.expressions.BinaryOperator +import de.fraunhofer.aisec.cpg.graph.statements.expressions.Reference import de.fraunhofer.aisec.cpg.graph.statements.expressions.UnaryOperator import de.fraunhofer.aisec.cpg.graph.types.* import kotlin.reflect.KClass @@ -49,6 +50,14 @@ class PythonLanguage : override val conjunctiveOperators = listOf("and") override val disjunctiveOperators = listOf("or") + /** + * You can either use `=` or `:=` in Python. But the latter is only available in a "named + * expression" (`a = (x := 1)`). We still need to include both however, otherwise + * [Reference.access] will not be set correctly in "named expressions". + */ + override val simpleAssignmentOperators: Set + get() = setOf("=", ":=") + /** * All operators which perform and assignment and an operation using lhs and rhs. See * https://docs.python.org/3/library/operator.html#in-place-operators