Hack to allow binary operators on userdata

This commit is contained in:
Deukhoofd 2019-01-21 16:07:24 +01:00
parent 97f3a4d879
commit bb51fb3853
No known key found for this signature in database
GPG Key ID: B4C087AC81641654
1 changed files with 3 additions and 2 deletions

View File

@ -41,8 +41,7 @@ namespace Upsilon.Binder
OutType = outType; OutType = outType;
} }
private static readonly BoundBinaryOperator[] Operators = new[] private static readonly BoundBinaryOperator[] Operators = {
{
// Math operators // Math operators
new BoundBinaryOperator(OperatorKind.Addition, Type.Number), new BoundBinaryOperator(OperatorKind.Addition, Type.Number),
new BoundBinaryOperator(OperatorKind.Subtraction, Type.Number), new BoundBinaryOperator(OperatorKind.Subtraction, Type.Number),
@ -97,6 +96,8 @@ namespace Upsilon.Binder
public static BoundBinaryOperator Bind(SyntaxKind operatorToken, Type left, Type right) public static BoundBinaryOperator Bind(SyntaxKind operatorToken, Type left, Type right)
{ {
if (left == Type.UserData) left = Type.Unknown;
if (right == Type.UserData) right = Type.Unknown;
OperatorKind kind; OperatorKind kind;
switch (operatorToken) switch (operatorToken)
{ {