diff --git a/src/compiler/analysis/emitter.cpp b/src/compiler/analysis/emitter.cpp index b7d006f7cbb1cb..536a4f4275c42f 100644 --- a/src/compiler/analysis/emitter.cpp +++ b/src/compiler/analysis/emitter.cpp @@ -1465,11 +1465,17 @@ void EmitterVisitor::visit(FileScopePtr file) { ReturnStatementPtr r(static_pointer_cast(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(); }