Add warnings when variable types are unknown

This commit is contained in:
Deukhoofd 2018-11-28 12:11:09 +01:00
parent 7ee230e20c
commit dbc7b4eb4f
No known key found for this signature in database
GPG Key ID: B4C087AC81641654
1 changed files with 8 additions and 1 deletions

View File

@ -317,10 +317,13 @@ namespace Upsilon.Binder
var boundVariable = TryBindVariable(name, isLocal, boundExpression, e.CommentData); var boundVariable = TryBindVariable(name, isLocal, boundExpression, e.CommentData);
if (boundVariable != null) if (boundVariable != null)
{ {
if (boundVariable.Type == Type.Unknown)
{
_diagnostics.LogUnknownVariableType(boundVariable.Name, variableExpression.Span);
}
var variable = new BoundVariableSymbol(boundVariable, variableExpression.Span); var variable = new BoundVariableSymbol(boundVariable, variableExpression.Span);
return new BoundVariableAssignment(variable, boundExpression, isLocal, e.Span); return new BoundVariableAssignment(variable, boundExpression, isLocal, e.Span);
} }
} }
return new BoundExpressionStatement(new BoundLiteralExpression(new ScriptNull(), e.Span), e.Span); return new BoundExpressionStatement(new BoundLiteralExpression(new ScriptNull(), e.Span), e.Span);
@ -335,6 +338,10 @@ namespace Upsilon.Binder
foreach (var identifierToken in s.Identifiers) foreach (var identifierToken in s.Identifiers)
{ {
var boundVariable = TryBindVariable(identifierToken.Name, isLocal, assignment, null); var boundVariable = TryBindVariable(identifierToken.Name, isLocal, assignment, null);
if (boundVariable.Type == Type.Unknown)
{
_diagnostics.LogUnknownVariableType(boundVariable.Name, identifierToken.Span);
}
ls.Add(boundVariable); ls.Add(boundVariable);
} }
return new BoundMultiAssignmentStatement(ls.ToImmutableArray(), assignment, s.Span); return new BoundMultiAssignmentStatement(ls.ToImmutableArray(), assignment, s.Span);