Type check an unary operation ('not', '-', '+' or '~').
(self, e: UnaryExpr)
| 4474 | return value |
| 4475 | |
| 4476 | def visit_unary_expr(self, e: UnaryExpr) -> Type: |
| 4477 | """Type check an unary operation ('not', '-', '+' or '~').""" |
| 4478 | operand_type = self.accept(e.expr) |
| 4479 | op = e.op |
| 4480 | if op == "not": |
| 4481 | result: Type = self.bool_type() |
| 4482 | self.chk.check_for_truthy_type(operand_type, e.expr) |
| 4483 | else: |
| 4484 | method = operators.unary_op_methods[op] |
| 4485 | result, method_type = self.check_method_call_by_name(method, operand_type, [], [], e) |
| 4486 | e.method_type = method_type |
| 4487 | return result |
| 4488 | |
| 4489 | def visit_index_expr(self, e: IndexExpr) -> Type: |
| 4490 | """Type check an index expression (base[index]). |
nothing calls this directly
no test coverage detected