vyperlang / vyper

Pythonic Smart Contract Language for the EVM
https://vyperlang.org
Other
4.84k stars 788 forks source link

Incorrect IR Node Annotation #4106

Open ritzdorf opened 4 months ago

ritzdorf commented 4 months ago

Version Information

The following creates an IR node for global attribute expr.parse_Attribute(). However, with the introduction of modules, it is no longer safe to assume that the attribute is from the self object.

if (varinfo := self.expr._expr_info.var_info) is not None:
    if varinfo.is_constant:
        return Expr.parse_value_expr(varinfo.decl_node.value, self.context)

    location = data_location_to_address_space(
        varinfo.location, self.context.is_ctor_context
    )

    ret = IRnode.from_list(
        varinfo.position.position,
        typ=varinfo.typ,
        location=location,
        annotation="self." + self.expr.attr,
    )
    ret._referenced_variables = {varinfo}

    return ret