Content-Length: 209023 | pFad | http://github.com/py2many/py2many/issues/628

1A Q: given a node, `a` in this case, how to know if its type is a container or not (list or dict in Python)? · Issue #628 · py2many/py2many · GitHub
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

Q: given a node, a in this case, how to know if its type is a container or not (list or dict in Python)? #628

Open
mw66 opened this issue Aug 11, 2024 · 1 comment

Comments

@mw66
Copy link

mw66 commented Aug 11, 2024

"dict_del": "a = {1: 1}; del a[1]; assert not a",

The last assert need to be translated into D as:

  assert(not(len(a) != 0))

In this case, given a node, a in this case, how to know if its type is a container or not (list or dict in Python)?

And also how to know its parent scope, i.e. not in this case, is a bool type?

Thanks.

@mw66 mw66 changed the title Q: given an expr, a in this case, how to know if its type is a container or not (list or dict in Python)? Q: given a node, a in this case, how to know if its type is a container or not (list or dict in Python)? Aug 12, 2024
@adsharma
Copy link
Collaborator

Please take a look at ASTxSubscript and other similar ASTx* constructs in astx.py

To infer "not a" as bool, I'd modify this code:
https://github.com/py2many/py2many/blob/main/py2many/inference.py#L375

and add an annotation like this:
https://github.com/py2many/py2many/blob/main/py2many/inference.py#L580

There is also a z3 based inference backend (py2may --typpete) that may already infer not a as bool.

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

No branches or pull requests

2 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/py2many/py2many/issues/628

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy