parse bool op symbol

pull/2099/head
alpharush 1 year ago
parent 5443132c2b
commit a61ca34226
  1. 4
      slither/vyper_parsing/ast/ast.py
  2. 4
      slither/vyper_parsing/expressions/expression_parsing.py

@ -316,10 +316,12 @@ def parse_aug_assign(raw: Dict) -> AugAssign:
def parse_unsupported(raw: Dict) -> ASTNode:
raise ParsingError("unsupported Vyper node", raw["ast_type"], raw.keys(), raw)
bool_op_ast_type_to_op_symbol = {"And": "&&", "Or": "||"}
def parse_bool_op(raw: Dict) -> BoolOp:
op_str = bool_op_ast_type_to_op_symbol[raw["op"]["ast_type"]]
return BoolOp(
op=raw["op"], values=[parse(x) for x in raw["values"]], **_extract_base_props(raw)
op=op_str, values=[parse(x) for x in raw["values"]], **_extract_base_props(raw)
)

@ -583,8 +583,8 @@ def parse_expression(expression: Dict, caller_context) -> "Expression":
lhs = parse_expression(expression.values[0], caller_context)
rhs = parse_expression(expression.values[1], caller_context)
# op = BinaryOperationType.get_type(expression.op) TODO update BoolOp AST
parsed_expr = BinaryOperation(lhs, rhs,BinaryOperationType.ANDAND)
op = BinaryOperationType.get_type(expression.op)
parsed_expr = BinaryOperation(lhs, op)
parsed_expr.set_offset(expression.src, caller_context.compilation_unit)
return parsed_expr

Loading…
Cancel
Save