Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
Pyston
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
Pyston
Commits
50e8fd65
Commit
50e8fd65
authored
May 12, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix closure bug with nested pass-through frames
parent
e9ce6176
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
2 deletions
+27
-2
src/codegen/ast_interpreter.cpp
src/codegen/ast_interpreter.cpp
+8
-1
src/codegen/irgen/irgenerator.cpp
src/codegen/irgen/irgenerator.cpp
+6
-1
test/tests/closure_test.py
test/tests/closure_test.py
+13
-0
No files found.
src/codegen/ast_interpreter.cpp
View file @
50e8fd65
...
...
@@ -814,7 +814,14 @@ Value ASTInterpreter::visit_makeClass(AST_MakeClass* mkclass) {
for
(
AST_expr
*
d
:
node
->
decorator_list
)
decorators
.
push_back
(
visit_expr
(
d
).
o
);
BoxedClosure
*
closure
=
scope_info
->
takesClosure
()
?
created_closure
:
0
;
BoxedClosure
*
closure
=
NULL
;
if
(
scope_info
->
takesClosure
())
{
if
(
this
->
scope_info
->
passesThroughClosure
())
closure
=
passed_closure
;
else
closure
=
created_closure
;
assert
(
closure
);
}
CLFunction
*
cl
=
wrapFunction
(
node
,
nullptr
,
node
->
body
,
source_info
);
Box
*
passed_globals
=
NULL
;
...
...
src/codegen/irgen/irgenerator.cpp
View file @
50e8fd65
...
...
@@ -1273,7 +1273,12 @@ private:
// TODO duplication with _createFunction:
CompilerVariable
*
created_closure
=
NULL
;
if
(
scope_info
->
takesClosure
())
{
created_closure
=
symbol_table
[
internString
(
CREATED_CLOSURE_NAME
)];
if
(
irstate
->
getScopeInfo
()
->
createsClosure
())
{
created_closure
=
symbol_table
[
internString
(
CREATED_CLOSURE_NAME
)];
}
else
{
assert
(
irstate
->
getScopeInfo
()
->
passesThroughClosure
());
created_closure
=
symbol_table
[
internString
(
PASSED_CLOSURE_NAME
)];
}
assert
(
created_closure
);
}
...
...
test/tests/closure_test.py
View file @
50e8fd65
...
...
@@ -69,3 +69,16 @@ def f6():
print
(
lambda
a
=
1
:
x
)()
f6
()
# Regression test: make sure we can handle two pass-through-closure frames in a row
def
f7
(
n
):
class
C
(
object
):
class
D
(
object
):
def
foo
(
self
):
return
n
return
C
.
D
c
=
f7
(
5
)()
print
c
.
foo
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment