From ba63f85df988bfc73168d913ed8a431a69836d90 Mon Sep 17 00:00:00 2001 From: "Tristan B. Kildaire" Date: Sun, 20 Feb 2022 16:37:45 +0200 Subject: [PATCH] Binary operator expressions now work --- source/tlang/compiler/typecheck/core.d | 15 +++++++++++++++ source/tlang/testing/typecheck/simple_1.t | 1 + test.d | 9 +-------- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/source/tlang/compiler/typecheck/core.d b/source/tlang/compiler/typecheck/core.d index f97c1f1..8b64f53 100644 --- a/source/tlang/compiler/typecheck/core.d +++ b/source/tlang/compiler/typecheck/core.d @@ -310,6 +310,21 @@ public final class TypeChecker */ Type vRhsType = popType(); Type vLhsType = popType(); + + /** + * TODO: + * Types must either BE THE SAME or BE COMPATIBLE + */ + if(isSameType(vLhsType, vRhsType)) + { + /* Left type + Right type = left/right type (just use left - it doesn't matter) */ + addType(vLhsType); + } + else + { + gprintln("Binary operator expression requires both types be same, but got '"~vRhsType.toString()~"' and '"~vLhsType.toString()~"'", DebugType.ERROR); + assert(false); + } /** diff --git a/source/tlang/testing/typecheck/simple_1.t b/source/tlang/testing/typecheck/simple_1.t index f72a5e7..22dbb20 100644 --- a/source/tlang/testing/typecheck/simple_1.t +++ b/source/tlang/testing/typecheck/simple_1.t @@ -1,6 +1,7 @@ module simple; int j = 1+func(2,test()); +j = 2+func(2,test()); int func(int x1, byte x2) { diff --git a/test.d b/test.d index 3375cda..de27560 100644 --- a/test.d +++ b/test.d @@ -21,13 +21,6 @@ asm asm { - mov RSP, R15; + mov R13B, 65; } - - int h = -1; - h = *((&h)-4); - import std.stdio; - writeln(h); - -}