Skip to content

Commit

Permalink
[Nemo] Misc nemo fixes
Browse files Browse the repository at this point in the history
Summary:
When running in "lint" mode, we should not report errors that rely on having
seen the whole program:
 - Dont report MissingAbstractMethodImpl, if there is a redeclared, or missing
base class
 - Dont assume that undefined constants have type string (potentially resulting
in BadArgumentType errors)
 - Dont report UseUndeclaredVariable to class statics, if the class has a
redeclared, or missing base class.

Test Plan:
No unexpected CodeErrors from:

<?php
class foo extends baz {}
interface buz { function fiz(); }
class bar extends foo implements buz {
  protected $x = null;
  protected static $a = array();
  protected function biz($params = array()) {
    $this->x = array_merge(self::$a, self::$a);
  }
}
function t(int $x) {
}
t(FIZZLE);

(previously reported self::$a as UseUndeclaredVariable, t(FIZZLE) as
BadArgumentType and MissingAbstractMethodImpl for class bar).

Reviewers: qigao, myang

Reviewed By: myang

CC: ps, mwilliams, myang

Differential Revision: 340737
  • Loading branch information
mwilliams authored and macvicar committed Oct 18, 2011
1 parent 7917c1e commit 934b2bd
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/compiler/analysis/analysis_result.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,8 @@ void AnalysisResult::analyzeProgram(bool system /* = false */) {
StringToFunctionScopePtrMap methods;
cls->collectMethods(ar, methods);
bool needAbstractMethodImpl =
(!cls->isAbstract() && !cls->isInterface());
(!cls->isAbstract() && !cls->isInterface() &&
!cls->derivesFromRedeclaring());
for (StringToFunctionScopePtrMap::const_iterator iterMethod =
methods.begin(); iterMethod != methods.end(); ++iterMethod) {
FunctionScopePtr func = iterMethod->second;
Expand Down
3 changes: 2 additions & 1 deletion src/compiler/analysis/constant_table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ TypePtr ConstantTable::check(BlockScopeRawPtr context,
}
}
Compiler::Error(Compiler::UseUndeclaredConstant, construct);
actualType = isClassScope ? Type::Variant : Type::String;
actualType = isClassScope || !Option::WholeProgram ?
Type::Variant : Type::String;
}
} else {
ASSERT(sym->isPresent());
Expand Down
3 changes: 0 additions & 3 deletions src/compiler/expression/static_member_expression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,6 @@ TypePtr StaticMemberExpression::inferTypes(AnalysisResultPtr ar,
VariableTable::NonPrivateStaticVars);
tp = Type::Variant;
}
if (!found && getScope()->isFirstPass()) {
Compiler::Error(Compiler::UseUndeclaredVariable, self);
}
m_valid = found || isRedeclared() || m_dynamicClass;
m_implementedType.reset();
return tp;
Expand Down

0 comments on commit 934b2bd

Please sign in to comment.