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

unimplemented: array membership for arrays of complex types #2637

Open
charles-cooper opened this issue Feb 8, 2022 · 2 comments
Open

unimplemented: array membership for arrays of complex types #2637

charles-cooper opened this issue Feb 8, 2022 · 2 comments
Labels
codegen issue with codegen enhancement

Comments

@charles-cooper
Copy link
Member

charles-cooper commented Feb 8, 2022

Version Information

  • vyper Version (output of vyper --version): v0.3.1

What's your issue about?

only the first word in each element is compared
for instance

struct Foo:
    x: uint256
    y: uint256

@external
def foo(f: Foo[1]) -> bool:
    t: Foo = Foo({x: 1, y: 2})
    return t in f

generates the following code. you can see only the first word of each element is compared.

                              /* t in f */ 
                              [seq,
                                [mstore, 288, 0],
                                [with,
                                  _result,
                                  288,
                                  [repeat,
                                    ix0,
                                    0,
                                    1,
                                    1,
                                    [if,
                                      [iszero, [xor, [mload, 224 <t>], [calldataload, [add, 4 <f>, [mul, 32, ix0]]]]],
                                      [seq, [mstore, _result, 1], break]]]],
                                [mload, 288]]]],

How can it be fixed?

@charles-cooper charles-cooper added the bug Bug that shouldn't change language semantics when fixed. label Feb 8, 2022
@charles-cooper charles-cooper added codegen issue with codegen bug - codegen and removed bug Bug that shouldn't change language semantics when fixed. bug - codegen labels Apr 15, 2022
@charles-cooper charles-cooper changed the title array membership broken for arrays of complex types array membership unimplemented for arrays of complex types Apr 15, 2022
@charles-cooper
Copy link
Member Author

this was blocked in #2633, so I am demoting this issue from bug to enhancement

@charles-cooper charles-cooper changed the title array membership unimplemented for arrays of complex types unimplemented: array membership for arrays of complex types Apr 15, 2022
@trocher
Copy link
Contributor

trocher commented Jan 22, 2023

Would it makes sense to move the following check that blocks non-base types to be on the left hand side to types_from_Compare in the semantic analysis as currently only SArrrayT is checked there ?

vyper/vyper/codegen/expr.py

Lines 400 to 405 in 02339df

# temporary kludge to block #2637 bug
# TODO actually fix the bug
if not left.typ._is_prim_word:
raise TypeMismatch(
"`in` not allowed for arrays of non-base types, tracked in issue #2637", self.expr
)

if any(isinstance(i, SArrayT) for i in left):
raise InvalidOperation(
"Left operand in membership comparison cannot be Array type", node.left
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
codegen issue with codegen enhancement
Projects
None yet
Development

No branches or pull requests

2 participants