From bdddf9f01d5f7d1868cf731228152d757927741a Mon Sep 17 00:00:00 2001 From: mwilliams Date: Thu, 18 Apr 2013 14:41:03 -0700 Subject: [PATCH] Arrays as class constants should be a parse time fatal We were detecting this in the emitter, which is too late, because the definition could be optimized out by then --- hphp/compiler/expression/assignment_expression.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hphp/compiler/expression/assignment_expression.cpp b/hphp/compiler/expression/assignment_expression.cpp index 119fdace7..2134c8b17 100644 --- a/hphp/compiler/expression/assignment_expression.cpp +++ b/hphp/compiler/expression/assignment_expression.cpp @@ -92,6 +92,10 @@ void AssignmentExpression::onParseRecur(AnalysisResultConstPtr ar, // ...as in ClassConstant statement // We are handling this one here, not in ClassConstant, purely because // we need "value" to store in constant table. + if (type->is(Type::KindOfArray)) { + parseTimeFatal(Compiler::NoError, + "Arrays are not allowed in class constants"); + } ConstantExpressionPtr exp = dynamic_pointer_cast(m_variable); scope->getConstants()->add(exp->getName(), type, m_value, ar, m_variable);