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

refactor: fix IRnode.from_list #3614

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
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
32 changes: 19 additions & 13 deletions vyper/codegen/ir_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,14 @@ def __init__(
error_msg: Optional[str] = None,
mutable: bool = True,
add_gas_estimate: int = 0,
encoding: Encoding = Encoding.VYPER,
encoding: Encoding = None,
is_self_call: bool = False,
passthrough_metadata: dict[str, Any] = None,
):
if args is None:
args = []
if encoding is None:
encoding = Encoding.VYPER

self.value = value
self.args = args
Expand Down Expand Up @@ -610,26 +612,30 @@ def from_list(
add_gas_estimate: int = 0,
is_self_call: bool = False,
passthrough_metadata: dict[str, Any] = None,
encoding: Encoding = Encoding.VYPER,
encoding: Encoding = None,
) -> "IRnode":
if isinstance(typ, str):
raise CompilerPanic(f"Expected type, not string: {typ}")

if isinstance(obj, IRnode):
ret = copy.copy(obj)
# note: this modify-and-returnclause is a little weird since
# the input gets modified. CC 20191121.
if typ is not None:
obj.typ = typ
if obj.source_pos is None:
obj.source_pos = source_pos
if obj.location is None:
obj.location = location
if obj.encoding is None:
obj.encoding = encoding
if obj.error_msg is None:
obj.error_msg = error_msg

return obj
ret.typ = typ
if source_pos is not None:
ret.source_pos = source_pos
if location is not None:
ret.location = location
if encoding is not None:
ret.encoding = encoding
if error_msg is not None:
ret.error_msg = error_msg
if add_gas_estimate != 0:
ret.add_gas_estimate = add_gas_estimate

return ret

elif not isinstance(obj, list):
return cls(
obj,
Expand Down
Loading