diff --git a/vyper/builtins/_convert.py b/vyper/builtins/_convert.py index 156bee418e..98c4fa7219 100644 --- a/vyper/builtins/_convert.py +++ b/vyper/builtins/_convert.py @@ -86,8 +86,8 @@ def _bytes_to_num(arg, out_typ, signed): num_zero_bits = ["mul", 8, ["sub", 32, _len]] elif is_bytes_m_type(arg.typ): num_zero_bits = 8 * (32 - arg.typ.m) - else: - raise CompilerPanic("unreachable") # pragma: notest + else: # pragma: nocover + raise CompilerPanic("unreachable") if signed: ret = sar(num_zero_bits, arg) @@ -359,8 +359,8 @@ def to_decimal(expr, arg, out_typ): # TODO: consider adding is_signed and bits to bool so we can use _int_to_fixed arg = ["mul", arg, 10**out_typ.decimals] return IRnode.from_list(arg, typ=out_typ) - else: - raise CompilerPanic("unreachable") # pragma: notest + else: # pragma: nocover + raise CompilerPanic("unreachable") @_input_types(IntegerT, DecimalT, BytesM_T, AddressT, BytesT, BoolT) diff --git a/vyper/builtins/_signatures.py b/vyper/builtins/_signatures.py index 6e6cf4c662..ab5854d68f 100644 --- a/vyper/builtins/_signatures.py +++ b/vyper/builtins/_signatures.py @@ -29,7 +29,7 @@ def process_arg(arg, expected_arg_type, context): if isinstance(expected_arg_type, VyperType): return Expr(arg, context).ir_node - raise CompilerPanic(f"Unexpected type: {expected_arg_type}") # pragma: notest + raise CompilerPanic(f"Unexpected type: {expected_arg_type}") # pragma: nocover def process_kwarg(kwarg_node, kwarg_settings, expected_kwarg_type, context): diff --git a/vyper/codegen/abi_encoder.py b/vyper/codegen/abi_encoder.py index 66d61a9c16..b227161d94 100644 --- a/vyper/codegen/abi_encoder.py +++ b/vyper/codegen/abi_encoder.py @@ -166,10 +166,10 @@ def abi_encode(dst, ir_node, context, bufsz, returns_len=False): size_bound = abi_t.size_bound() assert isinstance(bufsz, int) - if bufsz < size_bound: + if bufsz < size_bound: # pragma: nocover raise CompilerPanic("buffer provided to abi_encode not large enough") - if size_bound < dst.typ.memory_bytes_required: + if size_bound < dst.typ.memory_bytes_required: # pragma: nocover raise CompilerPanic("Bad ABI size calc") annotation = f"abi_encode {ir_node.typ}" @@ -208,7 +208,7 @@ def abi_encode(dst, ir_node, context, bufsz, returns_len=False): ir_ret.extend(encode_ir) static_ofst += e.typ.abi_type.embedded_static_size() - else: + else: # pragma: nocover raise CompilerPanic(f"unencodable type: {ir_node.typ}") # declare IR variables. @@ -221,7 +221,7 @@ def abi_encode(dst, ir_node, context, bufsz, returns_len=False): ir_ret.append(calc_len) elif abi_t.is_complex_type(): ir_ret.append("dyn_ofst") - else: + else: # pragma: nocover raise CompilerPanic(f"unknown type {ir_node.typ}") if abi_t.is_dynamic() and abi_t.is_complex_type(): diff --git a/vyper/codegen/arithmetic.py b/vyper/codegen/arithmetic.py index f14069384a..5a54d8d40b 100644 --- a/vyper/codegen/arithmetic.py +++ b/vyper/codegen/arithmetic.py @@ -286,7 +286,7 @@ def safe_div(x, y): if is_decimal_type(x.typ): lo, hi = typ.int_bounds - if max(abs(lo), abs(hi)) * typ.divisor > 2**256 - 1: + if max(abs(lo), abs(hi)) * typ.divisor > 2**256 - 1: # pragma: nocover # stub to prevent us from adding fixed point numbers we don't know # how to deal with raise UnimplementedException("safe_mul for decimal{typ.bits}x{typ.decimals}") @@ -340,8 +340,7 @@ def safe_mod(x, y): # def safe_pow(x: IRnode, y: IRnode) -> IRnode: def safe_pow(x, y): typ = x.typ - if not is_integer_type(x.typ): - # type checker should have caught this + if not is_integer_type(x.typ): # pragma: nocover raise TypeCheckFailure("non-integer pow") GE = "sge" if typ.is_signed else "ge" diff --git a/vyper/codegen/context.py b/vyper/codegen/context.py index af01c5b504..5ac8cdd758 100644 --- a/vyper/codegen/context.py +++ b/vyper/codegen/context.py @@ -211,12 +211,10 @@ def new_variable(self, name: str, typ: VyperType, is_mutable: bool = True) -> in var_size = typ.memory_bytes_required return self._new_variable(name, typ, var_size, False, is_mutable=is_mutable) - def fresh_varname(self, name: Optional[str] = None) -> str: + def fresh_varname(self, name: str) -> str: """ - return a unique + return a unique variable name """ - if name is None: - name = "var" t = self._internal_var_iter self._internal_var_iter += 1 return f"{name}{t}" @@ -251,4 +249,4 @@ def pp_constancy(self): return "a range expression" elif self.constancy == Constancy.Constant: return "a constant function" - raise CompilerPanic(f"unknown constancy in pp_constancy: {self.constancy}") + raise CompilerPanic(f"bad constancy: {self.constancy}") # pragma: nocover diff --git a/vyper/codegen/core.py b/vyper/codegen/core.py index 29f7228406..4262ad534a 100644 --- a/vyper/codegen/core.py +++ b/vyper/codegen/core.py @@ -178,14 +178,14 @@ def make_byte_array_copier(dst, src): def bytes_data_ptr(ptr): - if ptr.location is None: + if ptr.location is None: # pragma: nocover raise CompilerPanic("tried to modify non-pointer type") assert isinstance(ptr.typ, _BytestringT) return add_ofst(ptr, ptr.location.word_scale) def dynarray_data_ptr(ptr): - if ptr.location is None: + if ptr.location is None: # pragma: nocover raise CompilerPanic("tried to modify non-pointer type") assert isinstance(ptr.typ, DArrayT) return add_ofst(ptr, ptr.location.word_scale) @@ -510,8 +510,8 @@ def _get_element_ptr_tuplelike(parent, key): ofst = 0 # offset from parent start if parent.encoding == Encoding.ABI: - if parent.location == STORAGE: - raise CompilerPanic("storage variables should not be abi encoded") # pragma: notest + if parent.location in (STORAGE, TRANSIENT): # pragma: nocover + raise CompilerPanic("storage variables should not be abi encoded") member_t = typ.member_types[attrs[index]] @@ -544,7 +544,7 @@ def has_length_word(typ): def _get_element_ptr_array(parent, key, array_bounds_check): assert is_array_like(parent.typ) - if not is_integer_type(key.typ): + if not is_integer_type(key.typ): # pragma: nocover raise TypeCheckFailure(f"{key.typ} used as array index") subtype = parent.typ.value_type @@ -580,8 +580,8 @@ def _get_element_ptr_array(parent, key, array_bounds_check): ix.set_error_msg(f"{parent.typ} bounds check") if parent.encoding == Encoding.ABI: - if parent.location == STORAGE: - raise CompilerPanic("storage variables should not be abi encoded") # pragma: notest + if parent.location in (STORAGE, TRANSIENT): # pragma: nocover + raise CompilerPanic("storage variables should not be abi encoded") member_abi_t = subtype.abi_type @@ -607,8 +607,7 @@ def _get_element_ptr_mapping(parent, key): subtype = parent.typ.value_type key = unwrap_location(key) - # TODO when is key None? - if key is None or parent.location not in (STORAGE, TRANSIENT): + if parent.location not in (STORAGE, TRANSIENT): # pragma: nocover raise TypeCheckFailure("bad dereference on mapping {parent}[{key}]") return IRnode.from_list(["sha3_64", parent, key], typ=subtype, location=parent.location) @@ -630,18 +629,18 @@ def get_element_ptr(parent, key, array_bounds_check=True): elif is_array_like(typ): ret = _get_element_ptr_array(parent, key, array_bounds_check) - else: - raise CompilerPanic(f"get_element_ptr cannot be called on {typ}") # pragma: notest + else: # pragma: nocover + raise CompilerPanic(f"get_element_ptr cannot be called on {typ}") return b.resolve(ret) def LOAD(ptr: IRnode) -> IRnode: - if ptr.location is None: + if ptr.location is None: # pragma: nocover raise CompilerPanic("cannot dereference non-pointer type") op = ptr.location.load_op - if op is None: - raise CompilerPanic(f"unreachable {ptr.location}") # pragma: notest + if op is None: # pragma: nocover + raise CompilerPanic(f"unreachable {ptr.location}") return IRnode.from_list([op, ptr]) @@ -655,11 +654,11 @@ def eval_once_check(name): def STORE(ptr: IRnode, val: IRnode) -> IRnode: - if ptr.location is None: + if ptr.location is None: # pragma: nocover raise CompilerPanic("cannot dereference non-pointer type") op = ptr.location.store_op - if op is None: - raise CompilerPanic(f"unreachable {ptr.location}") # pragma: notest + if op is None: # pragma: nocover + raise CompilerPanic(f"unreachable {ptr.location}") _check = _freshname(f"{op}_") @@ -735,27 +734,28 @@ def dummy_node_for_type(typ): def _check_assign_bytes(left, right): - if right.typ.maxlen > left.typ.maxlen: - raise TypeMismatch(f"Cannot cast from {right.typ} to {left.typ}") # pragma: notest + if right.typ.maxlen > left.typ.maxlen: # pragma: nocover + raise TypeMismatch(f"Cannot cast from {right.typ} to {left.typ}") # stricter check for zeroing a byte array. - if right.value == "~empty" and right.typ.maxlen != left.typ.maxlen: - raise TypeMismatch(f"Cannot cast from empty({right.typ}) to {left.typ}") # pragma: notest + # TODO: these should be TypeCheckFailure instead of TypeMismatch + if right.value == "~empty" and right.typ.maxlen != left.typ.maxlen: # pragma: nocover + raise TypeMismatch(f"Cannot cast from empty({right.typ}) to {left.typ}") def _check_assign_list(left, right): def FAIL(): # pragma: no cover raise TypeCheckFailure(f"assigning {right.typ} to {left.typ}") - if left.value == "multi": + if left.value == "multi": # pragma: nocover # Cannot do something like [a, b, c] = [1, 2, 3] - FAIL() # pragma: notest + FAIL() if isinstance(left.typ, SArrayT): - if not is_array_like(right.typ): - FAIL() # pragma: notest - if left.typ.count != right.typ.count: - FAIL() # pragma: notest + if not is_array_like(right.typ): # pragma: nocover + FAIL() + if left.typ.count != right.typ.count: # pragma: nocover + FAIL() # TODO recurse into left, right if literals? check_assign( @@ -763,17 +763,17 @@ def FAIL(): # pragma: no cover ) if isinstance(left.typ, DArrayT): - if not isinstance(right.typ, DArrayT): - FAIL() # pragma: notest + if not isinstance(right.typ, DArrayT): # pragma: nocover + FAIL() - if left.typ.count < right.typ.count: - FAIL() # pragma: notest + if left.typ.count < right.typ.count: # pragma: nocover + FAIL() # stricter check for zeroing - if right.value == "~empty" and right.typ.count != left.typ.count: + if right.value == "~empty" and right.typ.count != left.typ.count: # pragma: nocover raise TypeCheckFailure( f"Bad type for clearing bytes: expected {left.typ} but got {right.typ}" - ) # pragma: notest + ) # TODO recurse into left, right if literals? check_assign( @@ -785,13 +785,13 @@ def _check_assign_tuple(left, right): def FAIL(): # pragma: no cover raise TypeCheckFailure(f"assigning {right.typ} to {left.typ}") - if not isinstance(right.typ, left.typ.__class__): - FAIL() # pragma: notest + if not isinstance(right.typ, left.typ.__class__): # pragma: nocover + FAIL() if isinstance(left.typ, StructT): for k in left.typ.member_types: - if k not in right.typ.member_types: - FAIL() # pragma: notest + if k not in right.typ.member_types: # pragma: nocover + FAIL() # TODO recurse into left, right if literals? check_assign( dummy_node_for_type(left.typ.member_types[k]), @@ -799,15 +799,15 @@ def FAIL(): # pragma: no cover ) for k in right.typ.member_types: - if k not in left.typ.member_types: - FAIL() # pragma: notest + if k not in left.typ.member_types: # pragma: nocover + FAIL() - if left.typ.name != right.typ.name: - FAIL() # pragma: notest + if left.typ.name != right.typ.name: # pragma: nocover + FAIL() else: - if len(left.typ.member_types) != len(right.typ.member_types): - FAIL() # pragma: notest + if len(left.typ.member_types) != len(right.typ.member_types): # pragma: nocover + FAIL() for left_, right_ in zip(left.typ.member_types, right.typ.member_types): # TODO recurse into left, right if literals? check_assign(dummy_node_for_type(left_), dummy_node_for_type(right_)) @@ -831,8 +831,8 @@ def FAIL(): # pragma: no cover elif left.typ._is_prim_word: # TODO once we propagate types from typechecker, introduce this check: - # if left.typ != right.typ: - # FAIL() # pragma: notest + # if left.typ != right.typ: # pragma: nocover + # FAIL() pass else: # pragma: no cover @@ -859,8 +859,8 @@ def reset_names(): def needs_clamp(t, encoding): if encoding == Encoding.VYPER: return False - if encoding != Encoding.ABI: - raise CompilerPanic("unreachable") # pragma: notest + if encoding != Encoding.ABI: # pragma: nocover + raise CompilerPanic("unreachable") if isinstance(t, (_BytestringT, DArrayT)): return True if isinstance(t, FlagT): @@ -872,7 +872,7 @@ def needs_clamp(t, encoding): if t._is_prim_word: return t not in (INT256_T, UINT256_T, BYTES32_T) - raise CompilerPanic("unreachable") # pragma: notest + raise CompilerPanic("unreachable") # pragma: nocover # Create an x=y statement, where the types may be compound @@ -1113,8 +1113,8 @@ def sar(bits, x): def clamp_bytestring(ir_node): t = ir_node.typ - if not isinstance(t, _BytestringT): - raise CompilerPanic(f"{t} passed to clamp_bytestring") # pragma: notest + if not isinstance(t, _BytestringT): # pragma: nocover + raise CompilerPanic(f"{t} passed to clamp_bytestring") ret = ["assert", ["le", get_bytearray_length(ir_node), t.maxlen]] return IRnode.from_list(ret, error_msg=f"{ir_node.typ} bounds check") @@ -1129,8 +1129,8 @@ def clamp_dyn_array(ir_node): # clampers for basetype def clamp_basetype(ir_node): t = ir_node.typ - if not t._is_prim_word: - raise CompilerPanic(f"{t} passed to clamp_basetype") # pragma: notest + if not t._is_prim_word: # pragma: nocover + raise CompilerPanic(f"{t} passed to clamp_basetype") # copy of the input ir_node = unwrap_location(ir_node) @@ -1168,8 +1168,8 @@ def int_clamp(ir_node, bits, signed=False): in bounds. (Consumers should use clamp_basetype instead which uses type-based dispatch and is a little safer.) """ - if bits >= 256: - raise CompilerPanic(f"invalid clamp: {bits}>=256 ({ir_node})") # pragma: notest + if bits >= 256: # pragma: nocover + raise CompilerPanic(f"invalid clamp: {bits}>=256 ({ir_node})") u = "u" if not signed else "" msg = f"{u}int{bits} bounds check" @@ -1193,7 +1193,7 @@ def int_clamp(ir_node, bits, signed=False): def bytes_clamp(ir_node: IRnode, n_bytes: int) -> IRnode: - if not (0 < n_bytes <= 32): + if not (0 < n_bytes <= 32): # pragma: nocover raise CompilerPanic(f"bad type: bytes{n_bytes}") msg = f"bytes{n_bytes} bounds check" with ir_node.cache_when_complex("val") as (b, val): diff --git a/vyper/codegen/expr.py b/vyper/codegen/expr.py index 9da5b24469..e87b216662 100644 --- a/vyper/codegen/expr.py +++ b/vyper/codegen/expr.py @@ -429,7 +429,7 @@ def parse_BinOp(self): ret = arithmetic.safe_mod(x, y) elif isinstance(self.expr.op, vy_ast.Pow): ret = arithmetic.safe_pow(x, y) - else: + else: # pragma: nocover raise CompilerPanic("Unreachable") return IRnode.from_list(b1.resolve(b2.resolve(ret)), typ=out_typ) @@ -539,8 +539,8 @@ def parse_Compare(self): op = "eq" elif isinstance(self.expr.op, vy_ast.NotEq): op = "ne" - else: - return # pragma: notest + else: # pragma: nocover + return # Compare (limited to 32) byte arrays. if isinstance(left.typ, _BytestringT) and isinstance(right.typ, _BytestringT): @@ -593,7 +593,7 @@ def parse_BoolOp(self): if isinstance(self.expr.op, vy_ast.Or): return Expr._logical_or(values) - raise TypeCheckFailure(f"Unexpected boolop: {self.expr.op}") # pragma: notest + raise TypeCheckFailure(f"Unexpected boolop: {self.expr.op}") # pragma: nocover @staticmethod def _logical_and(values): diff --git a/vyper/codegen/external_call.py b/vyper/codegen/external_call.py index ba89f3cace..1e50886baf 100644 --- a/vyper/codegen/external_call.py +++ b/vyper/codegen/external_call.py @@ -159,7 +159,7 @@ def _bool(x): default_return_value=call_kwargs.pop("default_return_value", None), ) - if len(call_kwargs) != 0: + if len(call_kwargs) != 0: # pragma: nocover raise TypeCheckFailure(f"Unexpected keyword arguments: {call_kwargs}") return ret diff --git a/vyper/codegen/ir_node.py b/vyper/codegen/ir_node.py index b1a71021c8..1df2932da1 100644 --- a/vyper/codegen/ir_node.py +++ b/vyper/codegen/ir_node.py @@ -49,7 +49,7 @@ class Encoding(Enum): # shortcut for chaining multiple cache_when_complex calls -# CMC 2023-08-10 remove this and scope_together _as soon as_ we have +# CMC 2023-08-10 remove this _as soon as_ we have # real variables in IR (that we can declare without explicit scoping - # needs liveness analysis). @contextlib.contextmanager @@ -80,49 +80,10 @@ def resolve(self, body): yield mb, scoped_ir_nodes -# create multiple with scopes if any of the items are complex, to force -# ordering of side effects. -@contextlib.contextmanager -def scope_together(ir_nodes, names): - assert len(ir_nodes) == len(names) - - should_scope = any(s._optimized.is_complex_ir for s in ir_nodes) - - class _Builder: - def resolve(self, body): - if not should_scope: - # uses of the variable have already been inlined - return body - - ret = body - # build with scopes from inside-out (hence reversed) - for arg, name in reversed(list(zip(ir_nodes, names))): - ret = ["with", name, arg, ret] - - if isinstance(body, IRnode): - return IRnode.from_list( - ret, typ=body.typ, location=body.location, encoding=body.encoding - ) - else: - return ret - - b = _Builder() - - if should_scope: - ir_vars = tuple( - IRnode.from_list(name, typ=arg.typ, location=arg.location, encoding=arg.encoding) - for (arg, name) in zip(ir_nodes, names) - ) - yield b, ir_vars - else: - # inline them - yield b, ir_nodes - - # this creates a magical block which maps to IR `with` class _WithBuilder: def __init__(self, ir_node, name, should_inline=False): - if should_inline and ir_node._optimized.is_complex_ir: + if should_inline and ir_node._optimized.is_complex_ir: # pragma: nocover # this can only mean trouble raise CompilerPanic("trying to inline a complex IR node") @@ -363,7 +324,7 @@ def __init__( # var_list names a variable number stack variables elif self.value == "var_list": for arg in self.args: - if not isinstance(arg.value, str) or len(arg.args) > 0: + if not isinstance(arg.value, str) or len(arg.args) > 0: # pragma: nocover raise CodegenPanic(f"var_list only takes strings: {self.args}") self.valency = 0 self._gas = 0 @@ -384,12 +345,7 @@ def __init__( else: self.valency = 1 self._gas = 3 - elif self.value is None: - self.valency = 1 - # None IRnodes always get compiled into something else, e.g. - # mzero or PUSH1 0, and the gas will get re-estimated then. - self._gas = 3 - else: + else: # pragma: nocover raise CompilerPanic(f"Invalid value for IR AST node: {self.value}") assert isinstance(self.args, list) @@ -511,12 +467,6 @@ def referenced_variables(self): def contains_self_call(self): return getattr(self, "is_self_call", False) or any(x.contains_self_call for x in self.args) - def __getitem__(self, i): - return self.to_list()[i] - - def __len__(self): - return len(self.to_list()) - # TODO this seems like a not useful and also confusing function # check if dead code and remove - CMC 2021-12-13 def to_list(self): @@ -612,7 +562,7 @@ def from_list( passthrough_metadata: dict[str, Any] = None, encoding: Encoding = Encoding.VYPER, ) -> "IRnode": - if isinstance(typ, str): + if isinstance(typ, str): # pragma: nocover raise CompilerPanic(f"Expected type, not string: {typ}") if isinstance(obj, IRnode): diff --git a/vyper/codegen/keccak256_helper.py b/vyper/codegen/keccak256_helper.py index 9c5f5eb1d0..a4f2d6dd0a 100644 --- a/vyper/codegen/keccak256_helper.py +++ b/vyper/codegen/keccak256_helper.py @@ -5,11 +5,11 @@ from vyper.exceptions import CompilerPanic from vyper.semantics.types.bytestrings import _BytestringT from vyper.semantics.types.shortcuts import BYTES32_T -from vyper.utils import SHA3_BASE, SHA3_PER_WORD, MemoryPositions, bytes_to_int, keccak256 +from vyper.utils import SHA3_BASE, SHA3_PER_WORD, MemoryPositions def _check_byteslike(typ): - if not isinstance(typ, _BytestringT) and typ != BYTES32_T: + if not isinstance(typ, _BytestringT) and typ != BYTES32_T: # pragma: nocover # NOTE this may be checked at a higher level, but just be safe raise CompilerPanic("keccak256 only accepts bytes-like objects") @@ -21,11 +21,6 @@ def _gas_bound(num_words): def keccak256_helper(to_hash, context): _check_byteslike(to_hash.typ) - # Can hash literals - # TODO this is dead code. - if isinstance(to_hash, bytes): - return IRnode.from_list(bytes_to_int(keccak256(to_hash)), typ=BYTES32_T) - # Can hash bytes32 objects # TODO: Want to generalize to all bytes_M if to_hash.typ == BYTES32_T: diff --git a/vyper/codegen/module.py b/vyper/codegen/module.py index 9a1395bb49..251deeac83 100644 --- a/vyper/codegen/module.py +++ b/vyper/codegen/module.py @@ -506,7 +506,7 @@ def generate_ir_for_module(module_t: ModuleT) -> tuple[IRnode, IRnode]: deploy_code.extend(ctor_internal_func_irs) else: - if immutables_len != 0: + if immutables_len != 0: # pragma: nocover raise CompilerPanic("unreachable") deploy_code.append(["deploy", 0, runtime, 0]) diff --git a/vyper/codegen/return_.py b/vyper/codegen/return_.py index 41fa11ab56..da585ff0a1 100644 --- a/vyper/codegen/return_.py +++ b/vyper/codegen/return_.py @@ -13,6 +13,7 @@ ) from vyper.codegen.ir_node import IRnode from vyper.evm.address_space import MEMORY +from vyper.exceptions import TypeCheckFailure Stmt = Any # mypy kludge @@ -24,8 +25,8 @@ def make_return_stmt(ir_val: IRnode, stmt: Any, context: Context) -> Optional[IR jump_to_exit = ["exit_to", func_t._ir_info.exit_sequence_label] if context.return_type is None: - if stmt.value is not None: - return None # triggers an exception + if stmt.value is not None: # pragma: nocover + raise TypeCheckFailure("bad return") else: # sanity typecheck diff --git a/vyper/codegen/stmt.py b/vyper/codegen/stmt.py index 263b0c25e8..b61d77a31d 100644 --- a/vyper/codegen/stmt.py +++ b/vyper/codegen/stmt.py @@ -182,7 +182,7 @@ def _get_last(ir): instantiate_msg = make_byte_array_copier(buf, msg_ir) else: buf = _get_last(msg_ir) - if not isinstance(buf, int): + if not isinstance(buf, int): # pragma: nocover raise CompilerPanic(f"invalid bytestring {buf}\n{self}") instantiate_msg = msg_ir @@ -414,9 +414,6 @@ def _is_terminated(code): # codegen a list of statements def parse_body(code, context, ensure_terminated=False): - if not isinstance(code, list): - return parse_stmt(code, context) - ir_node = ["seq"] for stmt in code: ir = parse_stmt(stmt, context) diff --git a/vyper/ir/compile_ir.py b/vyper/ir/compile_ir.py index 8b09ae454f..ac8631ff7b 100644 --- a/vyper/ir/compile_ir.py +++ b/vyper/ir/compile_ir.py @@ -385,8 +385,8 @@ def _height_of(witharg): # } elif code.value == "repeat": o = [] - if len(code.args) != 5: - raise CompilerPanic("bad number of repeat args") # pragma: notest + if len(code.args) != 5: # pragma: nocover + raise CompilerPanic("bad number of repeat args") i_name = code.args[0] start = code.args[1] @@ -1053,7 +1053,7 @@ def optimize_assembly(assembly): if not changed: return - raise CompilerPanic("infinite loop detected during assembly reduction") # pragma: notest + raise CompilerPanic("infinite loop detected during assembly reduction") # pragma: nocover def adjust_pc_maps(pc_maps, ofst): diff --git a/vyper/ir/optimizer.py b/vyper/ir/optimizer.py index 79e02f041d..75e9b46783 100644 --- a/vyper/ir/optimizer.py +++ b/vyper/ir/optimizer.py @@ -91,7 +91,7 @@ def _flip_comparison_op(opname): return opname.replace("g", "l") if "l" in opname: return opname.replace("l", "g") - raise CompilerPanic(f"bad comparison op {opname}") # pragma: notest + raise CompilerPanic(f"bad comparison op {opname}") # pragma: nocover # some annotations are really long. shorten them (except maybe in "verbose" mode?) @@ -304,7 +304,7 @@ def _conservative_eq(x, y): # -1 | x == -1 return finalize(args[1].value, []) - raise CompilerPanic("unreachable") # pragma: notest + raise CompilerPanic("unreachable") # pragma: nocover # -1 - x == ~x (definition of two's complement) if binop == "sub" and _int(args[0], SIGNED) == -1: