static string literals

This commit is contained in:
nub31
2026-03-01 00:12:16 +01:00
parent 16d27c76ab
commit faf506f409
5 changed files with 112 additions and 90 deletions

View File

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