mirror of
https://github.com/python/cpython.git
synced 2025-08-27 04:05:34 +00:00
gh-106812: Small stack effect fixes (#107759)
- Generalize the syntax for the type of a stack effect to allow a trailing `*`, so we can declare something as e.g. `PyCodeObject *`. - When generating assignments for stack effects, the type of the value on the stack should be the default (i.e., `PyObject *`) even when the variable copied to/from it has a different type, so that an appropriate cast is generated However, not when the variable is an array -- then the type is taken from the variable (as it is always `PyObject **`).
This commit is contained in:
parent
707018cc75
commit
2df58dcd50
3 changed files with 15 additions and 20 deletions
|
@ -252,12 +252,14 @@ class Parser(PLexer):
|
|||
|
||||
@contextual
|
||||
def stack_effect(self) -> StackEffect | None:
|
||||
# IDENTIFIER [':' IDENTIFIER] ['if' '(' expression ')']
|
||||
# IDENTIFIER [':' IDENTIFIER [TIMES]] ['if' '(' expression ')']
|
||||
# | IDENTIFIER '[' expression ']'
|
||||
if tkn := self.expect(lx.IDENTIFIER):
|
||||
type_text = ""
|
||||
if self.expect(lx.COLON):
|
||||
type_text = self.require(lx.IDENTIFIER).text.strip()
|
||||
if self.expect(lx.TIMES):
|
||||
type_text += " *"
|
||||
cond_text = ""
|
||||
if self.expect(lx.IF):
|
||||
self.require(lx.LPAREN)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue