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

Nested bool contexts give unexpected results #145

Open
achidlow opened this issue Mar 22, 2024 · 0 comments
Open

Nested bool contexts give unexpected results #145

achidlow opened this issue Mar 22, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@achidlow
Copy link
Contributor

Currently, entering a "bool context" (for example, the target of an if condition, or explicitly converting something to bool via bool(...)) is not properly handled when nested occurs.

from puyapy import Bytes, Contract, UInt64, op

class Oopsie(Contract):
    def approval_program(self) -> bool:
        empty = Bytes()
        one = UInt64(1)
        return bool(op.bitlen(empty or one))

    def clear_state_program(self) -> bool:
        return True

This will give the error message:

error: Invalid argument type "bool" for argument "a" when calling puyapy.op.bitlen

This is incorrect, it's a type union not a bool. We allow type unions in a bool context explicitly, in this case it should warn that it's not supported (a further improvement is to actually support this particular case, which is feasible since the underlying op code supports the type union).

achidlow added a commit that referenced this issue Mar 22, 2024
also improve error messages on signature mismatch with intrinsic op
achidlow added a commit that referenced this issue Mar 22, 2024
also improve error messages on signature mismatch with intrinsic op
achidlow added a commit that referenced this issue Mar 22, 2024
also improve error messages on signature mismatch with intrinsic op
achidlow added a commit that referenced this issue Mar 22, 2024
also improve error messages on signature mismatch with intrinsic op
@achidlow achidlow added the bug Something isn't working label Apr 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant