diff --git a/src/runtime/base/hphp_system.cpp b/src/runtime/base/hphp_system.cpp index 12fc3f7721b08..0d15ad6dbf893 100644 --- a/src/runtime/base/hphp_system.cpp +++ b/src/runtime/base/hphp_system.cpp @@ -92,17 +92,19 @@ void Globals::initialize() { } } -CVarRef Globals::declareConstant(CStrRef name, Variant &constant, - CVarRef value) { +bool Globals::declareConstant(CStrRef name, Variant &constant, + CVarRef value) { if (!value.isAllowedAsConstantValue()) { raise_warning("Constants may only evaluate to scalar values"); - return false_varNR; + return false; } if (!m_dynamicConstants.exists(name)) { m_dynamicConstants.set(name, value); constant = value; + return true; } - return value; + raise_warning("Constant %s already defined", name.data()); + return false; } void Globals::declareFunction(const char *name) { diff --git a/src/runtime/base/hphp_system.h b/src/runtime/base/hphp_system.h index bfa380e27a79d..7ab6e07d100dc 100644 --- a/src/runtime/base/hphp_system.h +++ b/src/runtime/base/hphp_system.h @@ -53,7 +53,7 @@ class Globals : public LVariableTable { public: Globals() : FVF(__autoload)(false) {} void initialize(); - CVarRef declareConstant(CStrRef name, Variant &constant, CVarRef value); + bool declareConstant(CStrRef name, Variant &constant, CVarRef value); void declareFunction(const char *name); void declareFunctionLit(CStrRef name); bool defined(CStrRef name); diff --git a/src/test/test_code_run.cpp b/src/test/test_code_run.cpp index ab03ac7a9ef4c..a237825882176 100644 --- a/src/test/test_code_run.cpp +++ b/src/test/test_code_run.cpp @@ -14629,6 +14629,10 @@ bool TestCodeRun::TestConstant() { "var_dump(BLAH);" "define('FOO', array(1,2,3));"); + MVCR("