Make sure condition for if statement is a boolean

This commit is contained in:
Deukhoofd 2019-01-31 15:18:21 +01:00
parent 2e08669509
commit 947904f097
No known key found for this signature in database
GPG Key ID: B4C087AC81641654
1 changed files with 5 additions and 6 deletions

View File

@ -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)