static string literals
This commit is contained in:
@@ -255,6 +255,24 @@ public class TypeChecker
|
||||
switch (expression.Operation)
|
||||
{
|
||||
case NodeExpressionBinary.Op.Add:
|
||||
{
|
||||
if (left.Type is NubTypeString)
|
||||
{
|
||||
if (right.Type is not NubTypeString)
|
||||
throw BasicError("Right hand side of string concatination operator must be a string", right);
|
||||
|
||||
return new TypedNodeExpressionBinary(expression.Tokens, NubTypeString.Instance, left, CheckExpressionBinaryOperation(expression.Operation), right);
|
||||
}
|
||||
|
||||
if (left.Type is not NubTypeSInt and not NubTypeUInt)
|
||||
throw BasicError($"Unsupported type for left hand side arithmetic operation: {left.Type}", left);
|
||||
|
||||
if (right.Type is not NubTypeSInt and not NubTypeUInt)
|
||||
throw BasicError($"Unsupported type for right hand side arithmetic operation: {right.Type}", right);
|
||||
|
||||
type = left.Type;
|
||||
break;
|
||||
}
|
||||
case NodeExpressionBinary.Op.Subtract:
|
||||
case NodeExpressionBinary.Op.Multiply:
|
||||
case NodeExpressionBinary.Op.Divide:
|
||||
|
||||
Reference in New Issue
Block a user