mirror of
https://github.com/luau-lang/luau.git
synced 2025-05-04 10:33:46 +01:00
Formatting.
This commit is contained in:
parent
ccef633a29
commit
8c486b8a5c
2 changed files with 16 additions and 68 deletions
|
@ -538,13 +538,9 @@ ControlFlow ConstraintGraphBuilder::visit(const ScopePtr& scope, AstStat* stat)
|
||||||
else if (auto s = stat->as<AstStatRepeat>())
|
else if (auto s = stat->as<AstStatRepeat>())
|
||||||
return visit(scope, s);
|
return visit(scope, s);
|
||||||
else if (stat->is<AstStatBreak>())
|
else if (stat->is<AstStatBreak>())
|
||||||
return FFlag::LuauLoopControlFlowAnalysis
|
return FFlag::LuauLoopControlFlowAnalysis ? ControlFlow::Breaks : ControlFlow::None;
|
||||||
? ControlFlow::Breaks
|
|
||||||
: ControlFlow::None;
|
|
||||||
else if (stat->is<AstStatContinue>())
|
else if (stat->is<AstStatContinue>())
|
||||||
return FFlag::LuauLoopControlFlowAnalysis
|
return FFlag::LuauLoopControlFlowAnalysis ? ControlFlow::Continues : ControlFlow::None;
|
||||||
? ControlFlow::Continues
|
|
||||||
: ControlFlow::None;
|
|
||||||
else if (auto r = stat->as<AstStatReturn>())
|
else if (auto r = stat->as<AstStatReturn>())
|
||||||
return visit(scope, r);
|
return visit(scope, r);
|
||||||
else if (auto e = stat->as<AstStatExpr>())
|
else if (auto e = stat->as<AstStatExpr>())
|
||||||
|
@ -1070,9 +1066,7 @@ ControlFlow ConstraintGraphBuilder::visit(const ScopePtr& scope, AstStatIf* ifSt
|
||||||
ScopePtr elseScope = childScope(ifStatement->elsebody ? ifStatement->elsebody : ifStatement, scope);
|
ScopePtr elseScope = childScope(ifStatement->elsebody ? ifStatement->elsebody : ifStatement, scope);
|
||||||
applyRefinements(elseScope, ifStatement->elseLocation.value_or(ifStatement->condition->location), refinementArena.negation(refinement));
|
applyRefinements(elseScope, ifStatement->elseLocation.value_or(ifStatement->condition->location), refinementArena.negation(refinement));
|
||||||
|
|
||||||
const ControlFlow guardClauseFlows = FFlag::LuauLoopControlFlowAnalysis
|
const ControlFlow guardClauseFlows = FFlag::LuauLoopControlFlowAnalysis ? ExitingControlFlows : ControlFlow::Returns | ControlFlow::Throws;
|
||||||
? ExitingControlFlows
|
|
||||||
: ControlFlow::Returns | ControlFlow :: Throws;
|
|
||||||
|
|
||||||
ControlFlow thencf = visit(thenScope, ifStatement->thenbody);
|
ControlFlow thencf = visit(thenScope, ifStatement->thenbody);
|
||||||
ControlFlow elsecf = ControlFlow::None;
|
ControlFlow elsecf = ControlFlow::None;
|
||||||
|
@ -1087,44 +1081,24 @@ ControlFlow ConstraintGraphBuilder::visit(const ScopePtr& scope, AstStatIf* ifSt
|
||||||
if (FFlag::LuauLoopControlFlowAnalysis)
|
if (FFlag::LuauLoopControlFlowAnalysis)
|
||||||
{
|
{
|
||||||
if (thencf == elsecf)
|
if (thencf == elsecf)
|
||||||
{
|
|
||||||
return thencf;
|
return thencf;
|
||||||
}
|
else if (matches(thencf, FunctionExitControlFlows) && matches(elsecf, FunctionExitControlFlows))
|
||||||
if (
|
|
||||||
matches(thencf, FunctionExitControlFlows)
|
|
||||||
&& matches(elsecf, FunctionExitControlFlows)
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return ControlFlow::MixedFunctionExit;
|
return ControlFlow::MixedFunctionExit;
|
||||||
}
|
else if (matches(thencf, LoopExitControlFlows) && matches(elsecf, LoopExitControlFlows))
|
||||||
if (
|
|
||||||
matches(thencf, LoopExitControlFlows)
|
|
||||||
&& matches(elsecf, LoopExitControlFlows)
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return ControlFlow::MixedLoopExit;
|
return ControlFlow::MixedLoopExit;
|
||||||
}
|
else if (matches(thencf, ExitingControlFlows) && matches(elsecf, ExitingControlFlows))
|
||||||
if (
|
|
||||||
matches(thencf, ExitingControlFlows)
|
|
||||||
&& matches(elsecf, ExitingControlFlows)
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return ControlFlow::MixedExit;
|
return ControlFlow::MixedExit;
|
||||||
}
|
else
|
||||||
return ControlFlow::None;
|
return ControlFlow::None;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (matches(thencf, ControlFlow::Returns | ControlFlow::Throws) && matches(elsecf, ControlFlow::Returns | ControlFlow::Throws))
|
if (matches(thencf, ControlFlow::Returns | ControlFlow::Throws) && matches(elsecf, ControlFlow::Returns | ControlFlow::Throws))
|
||||||
{
|
|
||||||
return ControlFlow::Returns;
|
return ControlFlow::Returns;
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
return ControlFlow::None;
|
return ControlFlow::None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
static bool occursCheck(TypeId needle, TypeId haystack)
|
static bool occursCheck(TypeId needle, TypeId haystack)
|
||||||
{
|
{
|
||||||
|
|
|
@ -367,13 +367,9 @@ ControlFlow TypeChecker::check(const ScopePtr& scope, const AstStat& program)
|
||||||
else if (auto repeat = program.as<AstStatRepeat>())
|
else if (auto repeat = program.as<AstStatRepeat>())
|
||||||
return check(scope, *repeat);
|
return check(scope, *repeat);
|
||||||
else if (program.is<AstStatBreak>())
|
else if (program.is<AstStatBreak>())
|
||||||
return FFlag::LuauLoopControlFlowAnalysis
|
return FFlag::LuauLoopControlFlowAnalysis ? ControlFlow::Breaks : ControlFlow::None;
|
||||||
? ControlFlow::Breaks
|
|
||||||
: ControlFlow::None;
|
|
||||||
else if (program.is<AstStatContinue>())
|
else if (program.is<AstStatContinue>())
|
||||||
return FFlag::LuauLoopControlFlowAnalysis
|
return FFlag::LuauLoopControlFlowAnalysis ? ControlFlow::Continues : ControlFlow::None;
|
||||||
? ControlFlow::Continues
|
|
||||||
: ControlFlow::None;
|
|
||||||
else if (auto return_ = program.as<AstStatReturn>())
|
else if (auto return_ = program.as<AstStatReturn>())
|
||||||
return check(scope, *return_);
|
return check(scope, *return_);
|
||||||
else if (auto expr = program.as<AstStatExpr>())
|
else if (auto expr = program.as<AstStatExpr>())
|
||||||
|
@ -766,9 +762,7 @@ ControlFlow TypeChecker::check(const ScopePtr& scope, const AstStatIf& statement
|
||||||
ScopePtr elseScope = childScope(scope, statement.elsebody ? statement.elsebody->location : statement.location);
|
ScopePtr elseScope = childScope(scope, statement.elsebody ? statement.elsebody->location : statement.location);
|
||||||
resolve(result.predicates, elseScope, false);
|
resolve(result.predicates, elseScope, false);
|
||||||
|
|
||||||
const ControlFlow guardClauseFlows = FFlag::LuauLoopControlFlowAnalysis
|
const ControlFlow guardClauseFlows = FFlag::LuauLoopControlFlowAnalysis ? ExitingControlFlows : ControlFlow::Returns | ControlFlow::Throws;
|
||||||
? ExitingControlFlows
|
|
||||||
: ControlFlow::Returns | ControlFlow :: Throws;
|
|
||||||
|
|
||||||
ControlFlow thencf = check(thenScope, *statement.thenbody);
|
ControlFlow thencf = check(thenScope, *statement.thenbody);
|
||||||
ControlFlow elsecf = ControlFlow::None;
|
ControlFlow elsecf = ControlFlow::None;
|
||||||
|
@ -783,44 +777,24 @@ ControlFlow TypeChecker::check(const ScopePtr& scope, const AstStatIf& statement
|
||||||
if (FFlag::LuauLoopControlFlowAnalysis)
|
if (FFlag::LuauLoopControlFlowAnalysis)
|
||||||
{
|
{
|
||||||
if (thencf == elsecf)
|
if (thencf == elsecf)
|
||||||
{
|
|
||||||
return thencf;
|
return thencf;
|
||||||
}
|
else if (matches(thencf, FunctionExitControlFlows) && matches(elsecf, FunctionExitControlFlows))
|
||||||
if (
|
|
||||||
matches(thencf, FunctionExitControlFlows)
|
|
||||||
&& matches(elsecf, FunctionExitControlFlows)
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return ControlFlow::MixedFunctionExit;
|
return ControlFlow::MixedFunctionExit;
|
||||||
}
|
else if (matches(thencf, LoopExitControlFlows) && matches(elsecf, LoopExitControlFlows))
|
||||||
if (
|
|
||||||
matches(thencf, LoopExitControlFlows)
|
|
||||||
&& matches(elsecf, LoopExitControlFlows)
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return ControlFlow::MixedLoopExit;
|
return ControlFlow::MixedLoopExit;
|
||||||
}
|
else if (matches(thencf, ExitingControlFlows) && matches(elsecf, ExitingControlFlows))
|
||||||
if (
|
|
||||||
matches(thencf, ExitingControlFlows)
|
|
||||||
&& matches(elsecf, ExitingControlFlows)
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return ControlFlow::MixedExit;
|
return ControlFlow::MixedExit;
|
||||||
}
|
else
|
||||||
return ControlFlow::None;
|
return ControlFlow::None;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (matches(thencf, ControlFlow::Returns | ControlFlow::Throws) && matches(elsecf, ControlFlow::Returns | ControlFlow::Throws))
|
if (matches(thencf, ControlFlow::Returns | ControlFlow::Throws) && matches(elsecf, ControlFlow::Returns | ControlFlow::Throws))
|
||||||
{
|
|
||||||
return ControlFlow::Returns;
|
return ControlFlow::Returns;
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
return ControlFlow::None;
|
return ControlFlow::None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
check(thenScope, *statement.thenbody);
|
check(thenScope, *statement.thenbody);
|
||||||
|
|
Loading…
Add table
Reference in a new issue