From d39bf0bcfedb1bec0a28a776e98fa71f9f5f4ad4 Mon Sep 17 00:00:00 2001 From: mwilliams Date: Wed, 17 Apr 2013 09:50:06 -0700 Subject: [PATCH] Method names should not be coerced to string Zend fatals if the type is not string, where hphp would coerce to string. In RepoAuthoritative mode, this meant that scalar expressions would be converted to strings at bytecode emission time, bypassing the fatal (or, in most cases, resulting in a different fatal). --- hphp/compiler/expression/dynamic_function_call.cpp | 6 +----- hphp/compiler/expression/object_method_expression.cpp | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/hphp/compiler/expression/dynamic_function_call.cpp b/hphp/compiler/expression/dynamic_function_call.cpp index b2deb2e1f..0bf522620 100644 --- a/hphp/compiler/expression/dynamic_function_call.cpp +++ b/hphp/compiler/expression/dynamic_function_call.cpp @@ -103,11 +103,7 @@ TypePtr DynamicFunctionCall::inferTypes(AnalysisResultPtr ar, TypePtr type, } } - if (!m_class && m_className.empty()) { - m_nameExp->inferAndCheck(ar, Type::Variant, false); - } else { - m_nameExp->inferAndCheck(ar, Type::String, false); - } + m_nameExp->inferAndCheck(ar, Type::Some, false); if (m_params) { for (int i = 0; i < m_params->getCount(); i++) { diff --git a/hphp/compiler/expression/object_method_expression.cpp b/hphp/compiler/expression/object_method_expression.cpp index 886bdce42..8c3416ecb 100644 --- a/hphp/compiler/expression/object_method_expression.cpp +++ b/hphp/compiler/expression/object_method_expression.cpp @@ -185,7 +185,7 @@ TypePtr ObjectMethodExpression::inferAndCheck(AnalysisResultPtr ar, m_bindClass = true; if (m_name.empty()) { - m_nameExp->inferAndCheck(ar, Type::String, false); + m_nameExp->inferAndCheck(ar, Type::Some, false); setInvokeParams(ar); // we have to use a variant to hold dynamic value return checkTypesImpl(ar, type, Type::Variant, coerce);