Make sure condition for if statement is a boolean
This commit is contained in:
parent
2e08669509
commit
947904f097
|
@ -60,12 +60,7 @@ namespace Upsilon.Binder
|
|||
}
|
||||
unboundFunctionStatement.Block =
|
||||
(BoundBlockStatement) BindBlockStatement(unboundFunctionStatement.UnboundBlock);
|
||||
var resultType = Scope.ReturnType;
|
||||
Scope = Scope.ParentScope;
|
||||
//var variable =
|
||||
// (ScriptFunctionVariableSymbol) unboundFunctionStatement.Scope.ParentScope.Variables[
|
||||
// unboundFunctionStatement];
|
||||
//variable.IsBound = true;
|
||||
}
|
||||
_unboundFunctions.Clear();
|
||||
return new BoundScript((BoundBlockStatement) bound, e.Span, Scope, fileName, _script);
|
||||
|
@ -465,7 +460,7 @@ namespace Upsilon.Binder
|
|||
return new BoundVariableExpression(boundVariable, e.Span);
|
||||
}
|
||||
|
||||
private BoundStatement BindExpressionStatement(ExpressionStatementSyntax s)
|
||||
private BoundExpressionStatement BindExpressionStatement(ExpressionStatementSyntax s)
|
||||
{
|
||||
var exp = BindExpression(s.Expression);
|
||||
return new BoundExpressionStatement(exp, s.Span);
|
||||
|
@ -620,6 +615,10 @@ namespace Upsilon.Binder
|
|||
{
|
||||
Scope = new BoundScope(Scope);
|
||||
var condition = BindExpressionStatement(e.Condition);
|
||||
if (condition.Expression.Type != Type.Boolean && condition.Expression.Type != Type.Unknown)
|
||||
{
|
||||
_diagnostics.LogError("Condition for if statement should be a boolean.", condition.Span);
|
||||
}
|
||||
var block = BindBlockStatement(e.Block);
|
||||
Scope = Scope.ParentScope;
|
||||
if (e.NextElseIfStatement != null)
|
||||
|
|
Loading…
Reference in New Issue