-
-
Notifications
You must be signed in to change notification settings - Fork 33.9k
gh-143504: Expose CELL status of a symbol in symtable (GH-143504) #143549
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
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: AN Long <aisk@users.noreply.github.com>
|
I'll fix this in a while, my apologies for quite a big fault in the code actually |
Lib/test/test_symtable.py
Outdated
| outer = find_block(top, "outer") | ||
| self.assertIn("x",outer.get_cells()) | ||
| self.assertTrue(outer.lookup("x").is_cell()) | ||
| self.assertFalse(outer.lookup("inner").is_cell()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's put this test next to test_free.
Lib/symtable.py
Outdated
| __frees = None | ||
| __globals = None | ||
| __nonlocals = None | ||
| __cells = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I was using it for another version of the code which didn't end up working out, I'll be removing it now.
Lib/symtable.py
Outdated
|
|
||
| def get_cells(self): | ||
| """Return a list of cell variable names in the table.""" | ||
| return [s.get_name() for s in self.get_symbols() if s.is_cell()] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This probably belongs next to get_frees.
|
@iritkatriel I was forced to force push the symtable branch due to me updating the branch before for the CI. |
Expose cell status in symtable.Symbol via new
is_cell()predicate and addget_cells()method to SymbolTable.Changes
Symbol.is_cell()method that returnsTrueif the symbol has the CELL flag.SymbolTable.get_cells()method that returns an iterable of cell variable names.test_cellstoLib/test/test_symtable.pyto verify the new API.Tests
test_cellstest using a closure pattern (outer -> inneraccessingx).