string fix
This commit is contained in:
@@ -758,6 +758,7 @@ public class QBEGenerator
|
|||||||
|
|
||||||
private static string EmitBinaryInstructionForOperator(BinaryOperator op, TypeNode type)
|
private static string EmitBinaryInstructionForOperator(BinaryOperator op, TypeNode type)
|
||||||
{
|
{
|
||||||
|
// todo(nub31): Add support for string concatenation. Currently this expects ints or floats and will treat strings as ints
|
||||||
return op switch
|
return op switch
|
||||||
{
|
{
|
||||||
BinaryOperator.RightShift => type switch
|
BinaryOperator.RightShift => type switch
|
||||||
|
|||||||
@@ -358,13 +358,13 @@ public sealed class TypeChecker
|
|||||||
case BinaryOperatorSyntax.Plus:
|
case BinaryOperatorSyntax.Plus:
|
||||||
{
|
{
|
||||||
var left = CheckExpression(expression.Left);
|
var left = CheckExpression(expression.Left);
|
||||||
if (left.Type is IntTypeNode or FloatTypeNode or StringTypeNode or StringTypeNode)
|
if (left.Type is IntTypeNode or FloatTypeNode or StringTypeNode or CStringTypeNode)
|
||||||
{
|
{
|
||||||
var right = CheckExpression(expression.Right, left.Type);
|
var right = CheckExpression(expression.Right, left.Type);
|
||||||
return new BinaryExpressionNode(left.Type, left, op, right);
|
return new BinaryExpressionNode(left.Type, left, op, right);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new TypeCheckerException(Diagnostic.Error("The plus operator must be used with int, float or string types").At(expression.Left).Build());
|
throw new TypeCheckerException(Diagnostic.Error("The plus operator must be used with int, float, cstring or string types").At(expression.Left).Build());
|
||||||
}
|
}
|
||||||
case BinaryOperatorSyntax.Minus:
|
case BinaryOperatorSyntax.Minus:
|
||||||
case BinaryOperatorSyntax.Multiply:
|
case BinaryOperatorSyntax.Multiply:
|
||||||
|
|||||||
@@ -9,12 +9,10 @@ export struct Human
|
|||||||
|
|
||||||
extern "main" func main(args: []cstring): i64
|
extern "main" func main(args: []cstring): i64
|
||||||
{
|
{
|
||||||
let x = [1]Human
|
let x: cstring = "test"
|
||||||
|
|
||||||
x[0] = {
|
x = x + "uwu"
|
||||||
name = "oliver"
|
|
||||||
}
|
|
||||||
|
|
||||||
puts(x[0].name)
|
puts(x)
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user