Skip to content

Commit

Permalink
Ensure that Unit::m_mainReturn is static
Browse files Browse the repository at this point in the history
When we pull a unit from the repo, Unit::m_mainReturn is
made static. But eval bypasses the repo so we need to ensure
its static at emission time too.
  • Loading branch information
mwilliams authored and sgolemon committed Jul 27, 2012
1 parent 0fbc5c9 commit 3b70e84
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/compiler/analysis/emitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1465,11 +1465,17 @@ void EmitterVisitor::visit(FileScopePtr file) {
ReturnStatementPtr r(static_pointer_cast<ReturnStatement>(s));
Variant v(Variant::nullInit);
if (r->getRetExp() &&
(!r->getRetExp()->getScalarValue(v) ||
v.isArray())) {
!r->getRetExp()->getScalarValue(v)) {
TV_WRITE_UNINIT(&mainReturn);
goto fail;
}
if (v.isString()) {
v = String(StringData::GetStaticString(v.asCStrRef().get()));
} else if (v.isArray()) {
v = Array(ArrayData::GetScalarArray(v.asCArrRef().get()));
} else {
ASSERT(!IS_REFCOUNTED_TYPE(v.getType()));
}
mainReturn = *v.getTypedAccessor();
m_ue.returnSeen();
}
Expand Down

0 comments on commit 3b70e84

Please sign in to comment.