repos / gbc

GBC - Go B Compiler
git clone https://github.com/xplshn/gbc.git

commit
3a9a9ac
parent
3f80acc
author
xplshn
date
2025-09-10 02:59:10 +0000 UTC
a

Signed-off-by: xplshn <[email protected]>
31 files changed,  +216, -951
M pkg/ast/ast.go
+1, -3
 1@@ -348,9 +348,7 @@ func NewDirective(tok token.Token, name string) *Node {
 2 }
 3 
 4 func FoldConstants(node *Node) *Node {
 5-	if node == nil {
 6-		return nil
 7-	}
 8+	if node == nil { return nil }
 9 
10 	switch d := node.Data.(type) {
11 	case AssignNode: d.Rhs = FoldConstants(d.Rhs); node.Data = d
M pkg/cli/cli.go
+1, -3
 1@@ -589,9 +589,7 @@ func (a *App) formatFlagGroup(sb *strings.Builder, group FlagGroup, indent *Inde
 2 
 3 func getTerminalWidth() int {
 4 	width, _, err := term.GetSize(int(os.Stdout.Fd()))
 5-	if err != nil {
 6-		return 80
 7-	}
 8+	if err != nil { return 80 }
 9 	if width < 20 {
10 		return 20
11 	}
M pkg/codegen/codegen_helpers.go
+23, -46
 1@@ -357,8 +357,7 @@ func (ctx *Context) codegenUnaryOp(node *ast.Node) (ir.Value, bool) {
 2 		} else {
 3 			ctx.addInstr(&ir.Instruction{Op: ir.OpSub, Typ: valType, Result: res, Args: []ir.Value{&ir.Const{Value: 0}, val}})
 4 		}
 5-	case token.Plus:
 6-		return val, false
 7+	case token.Plus: return val, false
 8 	case token.Not:
 9 		wordType := ir.GetType(nil, ctx.wordSize)
10 		ctx.addInstr(&ir.Instruction{Op: ir.OpCEq, Typ: wordType, OperandType: valType, Result: res, Args: []ir.Value{val, &ir.Const{Value: 0}}})
11@@ -909,55 +908,33 @@ func getBinaryOpAndType(op token.Type, resultAstType *ast.BxType, wordSize int)
12 	if resultAstType != nil && (resultAstType.Kind == ast.TYPE_FLOAT || resultAstType.Kind == ast.TYPE_LITERAL_FLOAT) {
13 		typ := ir.GetType(resultAstType, wordSize)
14 		switch op {
15-		case token.Plus, token.PlusEq, token.EqPlus:
16-			return ir.OpAddF, typ
17-		case token.Minus, token.MinusEq, token.EqMinus:
18-			return ir.OpSubF, typ
19-		case token.Star, token.StarEq, token.EqStar:
20-			return ir.OpMulF, typ
21-		case token.Slash, token.SlashEq, token.EqSlash:
22-			return ir.OpDivF, typ
23-		case token.Rem, token.RemEq, token.EqRem:
24-			return ir.OpRemF, typ
25-		case token.EqEq:
26-			return ir.OpCEq, typ
27-		case token.Neq:
28-			return ir.OpCNeq, typ
29-		case token.Lt:
30-			return ir.OpCLt, typ
31-		case token.Gt:
32-			return ir.OpCGt, typ
33-		case token.Lte:
34-			return ir.OpCLe, typ
35-		case token.Gte:
36-			return ir.OpCGe, typ
37+		case token.Plus, token.PlusEq, token.EqPlus: return ir.OpAddF, typ
38+		case token.Minus, token.MinusEq, token.EqMinus: return ir.OpSubF, typ
39+		case token.Star, token.StarEq, token.EqStar: return ir.OpMulF, typ
40+		case token.Slash, token.SlashEq, token.EqSlash: return ir.OpDivF, typ
41+		case token.Rem, token.RemEq, token.EqRem: return ir.OpRemF, typ
42+		case token.EqEq: return ir.OpCEq, typ
43+		case token.Neq: return ir.OpCNeq, typ
44+		case token.Lt: return ir.OpCLt, typ
45+		case token.Gt: return ir.OpCGt, typ
46+		case token.Lte: return ir.OpCLe, typ
47+		case token.Gte: return ir.OpCGe, typ
48 		}
49 	}
50 
51 	typ := ir.GetType(resultAstType, wordSize)
52 	switch op {
53-	case token.Plus, token.PlusEq, token.EqPlus:
54-		return ir.OpAdd, typ
55-	case token.Minus, token.MinusEq, token.EqMinus:
56-		return ir.OpSub, typ
57-	case token.Star, token.StarEq, token.EqStar:
58-		return ir.OpMul, typ
59-	case token.Slash, token.SlashEq, token.EqSlash:
60-		return ir.OpDiv, typ
61-	case token.Rem, token.RemEq, token.EqRem:
62-		return ir.OpRem, typ
63-	case token.And, token.AndEq, token.EqAnd:
64-		return ir.OpAnd, typ
65-	case token.Or, token.OrEq, token.EqOr:
66-		return ir.OpOr, typ
67-	case token.Xor, token.XorEq, token.EqXor:
68-		return ir.OpXor, typ
69-	case token.Shl, token.ShlEq, token.EqShl:
70-		return ir.OpShl, typ
71-	case token.Shr, token.ShrEq, token.EqShr:
72-		return ir.OpShr, typ
73-	case token.EqEq:
74-		return ir.OpCEq, typ
75+	case token.Plus, token.PlusEq, token.EqPlus: return ir.OpAdd, typ
76+	case token.Minus, token.MinusEq, token.EqMinus: return ir.OpSub, typ
77+	case token.Star, token.StarEq, token.EqStar: return ir.OpMul, typ
78+	case token.Slash, token.SlashEq, token.EqSlash: return ir.OpDiv, typ
79+	case token.Rem, token.RemEq, token.EqRem: return ir.OpRem, typ
80+	case token.And, token.AndEq, token.EqAnd: return ir.OpAnd, typ
81+	case token.Or, token.OrEq, token.EqOr: return ir.OpOr, typ
82+	case token.Xor, token.XorEq, token.EqXor: return ir.OpXor, typ
83+	case token.Shl, token.ShlEq, token.EqShl: return ir.OpShl, typ
84+	case token.Shr, token.ShrEq, token.EqShr: return ir.OpShr, typ
85+	case token.EqEq: return ir.OpCEq, typ
86 	case token.Neq:
87 		return ir.OpCNeq, typ
88 	case token.Lt:
M pkg/codegen/qbe_backend.go
+2, -4
 1@@ -486,8 +486,7 @@ func (b *qbeBackend) formatValue(v ir.Value) string {
 2 			return fmt.Sprintf("s_%f", float64(float32Val))
 3 		}
 4 		return fmt.Sprintf("%s_%f", b.formatType(val.Typ), val.Value)
 5-	case *ir.Global:
 6-		return "$" + val.Name
 7+	case *ir.Global: return "$" + val.Name
 8 	case *ir.Temporary:
 9 		safeName := strings.NewReplacer(".", "_", "[", "_", "]", "_").Replace(val.Name)
10 		if val.ID == -1 {
11@@ -497,8 +496,7 @@ func (b *qbeBackend) formatValue(v ir.Value) string {
12 			return fmt.Sprintf("%%.%s_%d", safeName, val.ID)
13 		}
14 		return fmt.Sprintf("%%t%d", val.ID)
15-	case *ir.Label:
16-		return "@" + val.Name
17+	case *ir.Label: return "@" + val.Name
18 	default:
19 		return ""
20 	}
M pkg/config/config.go
+1, -3
 1@@ -175,9 +175,7 @@ func (c *Config) SetTarget(hostOS, hostArch, targetFlag string) {
 2 	if targetFlag != "" {
 3 		parts := strings.SplitN(targetFlag, "/", 2)
 4 		c.BackendName = parts[0]
 5-		if len(parts) > 1 {
 6-			c.BackendTarget = parts[1]
 7-		}
 8+		if len(parts) > 1 { c.BackendTarget = parts[1] }
 9 	}
10 
11 	validQBETargets := map[string]string{
M pkg/typeChecker/typeChecker.go
+6, -12
 1@@ -149,14 +149,10 @@ func (tc *TypeChecker) getAlignof(typ *ast.BxType) int64 {
 2 		return int64(tc.wordSize)
 3 	}
 4 	switch typ.Kind {
 5-	case ast.TYPE_VOID:
 6-		return 1
 7-	case ast.TYPE_POINTER:
 8-		return int64(tc.wordSize)
 9-	case ast.TYPE_ARRAY:
10-		return tc.getAlignof(typ.Base)
11-	case ast.TYPE_PRIMITIVE, ast.TYPE_FLOAT, ast.TYPE_ENUM:
12-		return tc.getSizeof(typ)
13+	case ast.TYPE_VOID: return 1
14+	case ast.TYPE_POINTER: return int64(tc.wordSize)
15+	case ast.TYPE_ARRAY: return tc.getAlignof(typ.Base)
16+	case ast.TYPE_PRIMITIVE, ast.TYPE_FLOAT, ast.TYPE_ENUM: return tc.getSizeof(typ)
17 	case ast.TYPE_STRUCT:
18 		var maxAlign int64 = 1
19 		for _, field := range typ.Fields {
20@@ -175,10 +171,8 @@ func (tc *TypeChecker) getSizeof(typ *ast.BxType) int64 {
21 		return int64(tc.wordSize)
22 	}
23 	switch typ.Kind {
24-	case ast.TYPE_VOID:
25-		return 0
26-	case ast.TYPE_POINTER:
27-		return int64(tc.wordSize)
28+	case ast.TYPE_VOID: return 0
29+	case ast.TYPE_POINTER: return int64(tc.wordSize)
30 	case ast.TYPE_ARRAY:
31 		elemSize := tc.getSizeof(typ.Base)
32 		var arrayLen int64 = 1
M pkg/util/util.go
+1, -3
 1@@ -35,9 +35,7 @@ func findFileAndLine(tok token.Token) (string, int, int) {
 2 
 3 func callerFile(skip int) string {
 4 	_, file, _, ok := runtime.Caller(skip)
 5-	if !ok {
 6-		return "<unknown>"
 7-	}
 8+	if !ok { return "<unknown>" }
 9 	return filepath.Base(file)
10 }
11 
M tests/arrays.bx
+40, -81
  1@@ -14,130 +14,110 @@ type enum Color {
  2 };
  3 
  4 void demo_integer_arrays() {
  5-    printf("\n-- Integer arrays --\n");
  6+    printf("\nInteger arrays:\n");
  7 
  8-    // Signed integer types
  9     int int_array[3];
 10     int8 int8_array[3];
 11     int16 int16_array[3];
 12     int32 int32_array[3];
 13     int64 int64_array[3];
 14-
 15-    // Unsigned integer types
 16     uint uint_array[3];
 17     uint8 uint8_array[3];
 18     uint16 uint16_array[3];
 19     uint32 uint32_array[3];
 20     uint64 uint64_array[3];
 21-
 22-    // Byte type (alias for uint8)
 23     byte byte_array[3];
 24 
 25-    // Initialize and display int array
 26     int_array[0] = -100;
 27     int_array[1] = 0;
 28     int_array[2] = 100;
 29-    printf("int array: [%d, %d, %d]\n", int_array[0], int_array[1], int_array[2]);
 30+    printf("int: [%d, %d, %d]\n", int_array[0], int_array[1], int_array[2]);
 31 
 32-    // Initialize and display int8 array
 33     int8_array[0] = -50;
 34     int8_array[1] = 0;
 35     int8_array[2] = 50;
 36-    printf("int8 array: [%d, %d, %d]\n", int8_array[0], int8_array[1], int8_array[2]);
 37+    printf("int8: [%d, %d, %d]\n", int8_array[0], int8_array[1], int8_array[2]);
 38 
 39-    // Initialize and display int16 array
 40     int16_array[0] = -1000;
 41     int16_array[1] = 0;
 42     int16_array[2] = 1000;
 43-    printf("int16 array: [%d, %d, %d]\n", int16_array[0], int16_array[1], int16_array[2]);
 44+    printf("int16: [%d, %d, %d]\n", int16_array[0], int16_array[1], int16_array[2]);
 45 
 46-    // Initialize and display int32 array
 47     int32_array[0] = -100000;
 48     int32_array[1] = 0;
 49     int32_array[2] = 100000;
 50-    printf("int32 array: [%d, %d, %d]\n", int32_array[0], int32_array[1], int32_array[2]);
 51+    printf("int32: [%d, %d, %d]\n", int32_array[0], int32_array[1], int32_array[2]);
 52 
 53-    // Initialize and display int64 array
 54     int64_array[0] = -1000000;
 55     int64_array[1] = 0;
 56     int64_array[2] = 1000000;
 57-    printf("int64 array: [%ld, %ld, %ld]\n", int64_array[0], int64_array[1], int64_array[2]);
 58+    printf("int64: [%ld, %ld, %ld]\n", int64_array[0], int64_array[1], int64_array[2]);
 59 
 60-    // Initialize and display uint array
 61     uint_array[0] = 10;
 62     uint_array[1] = 20;
 63     uint_array[2] = 30;
 64-    printf("uint array: [%u, %u, %u]\n", uint_array[0], uint_array[1], uint_array[2]);
 65+    printf("uint: [%u, %u, %u]\n", uint_array[0], uint_array[1], uint_array[2]);
 66 
 67-    // Initialize and display uint8 array
 68     uint8_array[0] = 100;
 69     uint8_array[1] = 150;
 70     uint8_array[2] = 200;
 71-    printf("uint8 array: [%u, %u, %u]\n", uint8_array[0], uint8_array[1], uint8_array[2]);
 72+    printf("uint8: [%u, %u, %u]\n", uint8_array[0], uint8_array[1], uint8_array[2]);
 73 
 74-    // Initialize and display uint16 array
 75     uint16_array[0] = 1000;
 76     uint16_array[1] = 2000;
 77     uint16_array[2] = 3000;
 78-    printf("uint16 array: [%u, %u, %u]\n", uint16_array[0], uint16_array[1], uint16_array[2]);
 79+    printf("uint16: [%u, %u, %u]\n", uint16_array[0], uint16_array[1], uint16_array[2]);
 80 
 81-    // Initialize and display uint32 array
 82     uint32_array[0] = 100000;
 83     uint32_array[1] = 200000;
 84     uint32_array[2] = 300000;
 85-    printf("uint32 array: [%u, %u, %u]\n", uint32_array[0], uint32_array[1], uint32_array[2]);
 86+    printf("uint32: [%u, %u, %u]\n", uint32_array[0], uint32_array[1], uint32_array[2]);
 87 
 88-    // Initialize and display uint64 array
 89     uint64_array[0] = 1000000;
 90     uint64_array[1] = 2000000;
 91     uint64_array[2] = 3000000;
 92-    printf("uint64 array: [%lu, %lu, %lu]\n", uint64_array[0], uint64_array[1], uint64_array[2]);
 93+    printf("uint64: [%lu, %lu, %lu]\n", uint64_array[0], uint64_array[1], uint64_array[2]);
 94 
 95-    // Initialize and display byte array (as characters)
 96     byte_array[0] = 'A';
 97     byte_array[1] = 'B';
 98     byte_array[2] = 'C';
 99-    printf("byte array: [%c, %c, %c]\n", byte_array[0], byte_array[1], byte_array[2]);
100+    printf("byte: [%c, %c, %c]\n", byte_array[0], byte_array[1], byte_array[2]);
101 }
102 
103 void demo_float_arrays() {
104-    printf("\n-- Float arrays --\n");
105+    printf("\nFloat arrays:\n");
106 
107     float float_array[3];
108     float32 float32_array[3];
109     float64 float64_array[3];
110 
111-    // Initialize and display float array
112     float_array[0] = 1.1;
113     float_array[1] = 2.2;
114     float_array[2] = 3.3;
115-    printf("float array: [%.2f, %.2f, %.2f]\n", float_array[0], float_array[1], float_array[2]);
116+    printf("float: [%.2f, %.2f, %.2f]\n", float_array[0], float_array[1], float_array[2]);
117 
118-    // Initialize and display float32 array
119     float32_array[0] = 1.25;
120     float32_array[1] = 2.75;
121     float32_array[2] = 3.125;
122-    printf("float32 array: [%.3f, %.3f, %.3f]\n", float32_array[0], float32_array[1], float32_array[2]);
123+    printf("float32: [%.3f, %.3f, %.3f]\n", float32_array[0], float32_array[1], float32_array[2]);
124 
125-    // Initialize and display float64 array
126     float64_array[0] = 1.123456;
127     float64_array[1] = 2.789012;
128     float64_array[2] = 3.456789;
129-    printf("float64 array: [%.6f, %.6f, %.6f]\n", float64_array[0], float64_array[1], float64_array[2]);
130+    printf("float64: [%.6f, %.6f, %.6f]\n", float64_array[0], float64_array[1], float64_array[2]);
131 }
132 
133 void demo_bool_arrays() {
134-    printf("\n-- Bool arrays --\n");
135+    printf("\nBool arrays:\n");
136 
137     bool bool_array[4];
138 
139-    // Initialize boolean array
140-    bool_array[0] = 1;    // true
141-    bool_array[1] = 0;    // false
142-    bool_array[2] = 1;    // Non-zero is true
143-    bool_array[3] = 0;    // Zero is false
144+    bool_array[0] = 1;
145+    bool_array[1] = 0;
146+    bool_array[2] = 1;
147+    bool_array[3] = 0;
148 
149-    printf("bool array: [%s, %s, %s, %s]\n",
150+    printf("bool: [%s, %s, %s, %s]\n",
151            bool_array[0] ? "true" : "false",
152            bool_array[1] ? "true" : "false",
153            bool_array[2] ? "true" : "false",
154@@ -145,49 +125,41 @@ void demo_bool_arrays() {
155 }
156 
157 void demo_pointer_arrays() {
158-    printf("\n-- Pointer arrays --\n");
159+    printf("\nPointer arrays:\n");
160 
161     int values[3];
162     int* int_ptr_array[3];
163     byte* string_array[3];
164     void* void_ptr_array[3];
165 
166-    // Initialize some values
167     values[0] = 42;
168     values[1] = 84;
169     values[2] = 126;
170 
171-    // Initialize pointer array to point to values
172     int_ptr_array[0] = &values[0];
173     int_ptr_array[1] = &values[1];
174     int_ptr_array[2] = &values[2];
175 
176-    printf("int* array dereferenced: [%d, %d, %d]\n",
177+    printf("int*: [%d, %d, %d]\n",
178            *int_ptr_array[0], *int_ptr_array[1], *int_ptr_array[2]);
179 
180-    // Initialize string array
181     string_array[0] = "Hello";
182     string_array[1] = "World";
183     string_array[2] = "GBC";
184 
185-    printf("string array: [\"%s\", \"%s\", \"%s\"]\n",
186+    printf("string: [\"%s\", \"%s\", \"%s\"]\n",
187            string_array[0], string_array[1], string_array[2]);
188 
189-    // Initialize void pointer array (can point to any type)
190-    void_ptr_array[0] = &values[0];     // points to int
191-    void_ptr_array[1] = string_array[0]; // points to string
192-    void_ptr_array[2] = int_ptr_array;   // points to array
193-
194-    //printf("void* array addresses: [%p, %p, %p]\n",
195-    //       void_ptr_array[0], void_ptr_array[1], void_ptr_array[2]);
196+    void_ptr_array[0] = &values[0];
197+    void_ptr_array[1] = string_array[0];
198+    void_ptr_array[2] = int_ptr_array;
199 }
200 
201 void demo_struct_arrays() {
202-    printf("\n-- Struct arrays --\n");
203+    printf("\nStruct arrays:\n");
204 
205     Point point_array[3];
206 
207-    // Initialize struct array
208     point_array[0].x = 10;
209     point_array[0].y = 20;
210     point_array[0].name = "Origin";
211@@ -200,7 +172,7 @@ void demo_struct_arrays() {
212     point_array[2].y = 75;
213     point_array[2].name = "Point B";
214 
215-    printf("Point array:\n");
216+    printf("Points:\n");
217     i := 0;
218     while (i < 3) {
219         printf("  [%d]: (%d, %d) \"%s\"\n", i,
220@@ -210,35 +182,25 @@ void demo_struct_arrays() {
221 }
222 
223 void demo_enum_arrays() {
224-    printf("\n-- Enum arrays --\n");
225+    printf("\nEnum arrays:\n");
226 
227     Color color_array[4];
228 
229-    // Initialize enum array
230     color_array[0] = RED;
231     color_array[1] = GREEN;
232     color_array[2] = BLUE;
233     color_array[3] = YELLOW;
234 
235-    printf("Color array:\n");
236+    printf("Colors:\n");
237     i := 0;
238     while (i < 4) {
239         color_name := "";
240         switch (color_array[i]) {
241-            case RED:
242-                color_name = "RED";
243-                break;
244-            case GREEN:
245-                color_name = "GREEN";
246-                break;
247-            case BLUE:
248-                color_name = "BLUE";
249-                break;
250-            case YELLOW:
251-                color_name = "YELLOW";
252-                break;
253-            default:
254-                color_name = "UNKNOWN";
255+            case RED: color_name = "RED"; break;
256+            case GREEN: color_name = "GREEN"; break;
257+            case BLUE: color_name = "BLUE"; break;
258+            case YELLOW: color_name = "YELLOW"; break;
259+            default: color_name = "UNKNOWN";
260         }
261         printf("  [%d]: %s (%d)\n", i, color_name, color_array[i]);
262         i = i + 1;
263@@ -246,15 +208,13 @@ void demo_enum_arrays() {
264 }
265 
266 void demo_struct_pointer_arrays() {
267-    printf("\n-- Struct pointer arrays (dynamic) --\n");
268+    printf("\nStruct pointer arrays:\n");
269 
270     Point* point_ptr_array[2];
271 
272-    // Allocate structs dynamically
273     point_ptr_array[0] = malloc(sizeof(Point));
274     point_ptr_array[1] = malloc(sizeof(Point));
275 
276-    // Initialize dynamically allocated structs
277     point_ptr_array[0].x = 300;
278     point_ptr_array[0].y = 400;
279     point_ptr_array[0].name = "Dynamic A";
280@@ -263,7 +223,7 @@ void demo_struct_pointer_arrays() {
281     point_ptr_array[1].y = 250;
282     point_ptr_array[1].name = "Dynamic B";
283 
284-    printf("Dynamic Point* array:\n");
285+    printf("Dynamic points:\n");
286     i := 0;
287     while (i < 2) {
288         printf("  [%d]: (%d, %d) \"%s\"\n", i,
289@@ -273,8 +233,7 @@ void demo_struct_pointer_arrays() {
290 }
291 
292 int main() {
293-    printf("GBC array types test\n");
294-    printf("Quick run of arrays for core types.\n");
295+    printf("Array types test\n");
296 
297     demo_integer_arrays();
298     demo_float_arrays();
M tests/bxDecls.bx
+1, -9
 1@@ -4,23 +4,15 @@ puts(arg string){
 2     printf("%s\n", arg);
 3 }
 4 
 5-// TODO: Copilot: Make this yield an error: Tried to assign to undeclared identifier. Did you intend to use := ?
 6-// global_short_aaa = 10;  // Commented out - this is expected to be an error case
 7-
 8 global_short := 10;
 9-
10 auto global_auto := 20;
11-
12 auto global_multi_1, global_multi_2 := 30, 40;
13 
14 main() {
15     auto local_auto;
16     local_auto = 50;
17 
18-    // Test short declaration
19     local_short := 60;
20-
21-    // Test multi-short declaration
22     local_multi_short_1, local_multi_short_2 := 70, 80;
23 
24     if (global_short != 10) {
25@@ -48,6 +40,6 @@ main() {
26         return (1);
27     }
28 
29-    puts("PASS: All Bx declaration syntax seems to work.\n");
30+    puts("PASS: All Bx declaration syntax works.\n");
31     return (0);
32 }
M tests/casting.bx
+1, -6
 1@@ -1,16 +1,13 @@
 2-// Test casting behavior - only function-style casts allowed for simple types
 3 main() {
 4     extrn printf, exit;
 5 
 6     auto a = 42;
 7 
 8-    // testing some basic casting
 9     b := int(a);
10     c := (int(a) + 1);
11 
12     printf("Function-style casts: a=%d, int(a)=%d, (int(a)+1)=%d\n", a, b, c);
13 
14-    // testing pointer casting
15     ptr := &a;
16     byte_ptr := (byte*)ptr;
17     int_ptr := (int*)byte_ptr;
18@@ -18,17 +15,15 @@ main() {
19 
20     printf("Pointer casts work: value=%d\n", value);
21 
22-    // --- Others
23     n1 := int8(8);
24     n2 := int16(16);
25     n3 := int32(32);
26     n4 := int64(64);
27-    // -
28+    
29     printf("n1(int8) : %d\n", n1);
30     printf("n2(int16): %d\n", n2);
31     printf("n3(int32): %d\n", n3);
32     printf("n4(int64): %d\n", n4);
33-    // ---
34 
35     exit(0);
36 }
M tests/enums2.bx
+4, -11
 1@@ -18,17 +18,10 @@ TrafficLight get_next_light(current_light TrafficLight) {
 2 
 3 void print_action(light TrafficLight) {
 4 	switch (light) {
 5-	case RED:
 6-		printf("Light is RED. Action: Stop.\n");
 7-		break;
 8-	case YELLOW:
 9-		printf("Light is YELLOW. Action: Caution.\n");
10-		break;
11-	case GREEN:
12-		printf("Light is GREEN. Action: Go.\n");
13-		break;
14-	default:
15-		printf("Unknown light state.\n");
16+	case RED: printf("RED - Stop.\n"); break;
17+	case YELLOW: printf("YELLOW - Caution.\n"); break;
18+	case GREEN: printf("GREEN - Go.\n"); break;
19+	default: printf("Unknown light.\n");
20 	}
21 }
22 
M tests/enums3.bx
+2, -2
 1@@ -23,7 +23,7 @@ Shape create_shape(c Color, x int, y int) {
 2 
 3 void print_shape(s Shape) {
 4     color_names := []byte*{ "RED", "GREEN", "BLUE", "YELLOW" };
 5-    printf("Shape -> Color: %s, Position: (%d, %d)\n",
 6+    printf("Shape: %s at (%d, %d)\n",
 7            color_names[s.shape_color], s.x_pos, s.y_pos);
 8 }
 9 
10@@ -51,7 +51,7 @@ int main() {
11     sp.shape_color = colors[(int(sp.shape_color) + 1) % 4];
12     print_shape(sp);
13 
14-    printf("\nThe final X position is: %d\n", get_shape_x(sp));
15+    printf("\nFinal X position: %d\n", get_shape_x(sp));
16 
17     return (0);
18 }
M tests/escapes.bx
+36, -52
  1@@ -5,143 +5,127 @@ main() {
  2     auto passed = 0;
  3     auto total = 0;
  4 
  5-    printf("=== Escape Sequence Parser Tests ===\n");
  6+    printf("Escape sequence tests\n");
  7 
  8-    // Test 1: Basic escape sequences
  9-    printf("\n--- Testing Basic Escape Sequences ---\n");
 10+    printf("\nBasic escapes:\n");
 11     total++;
 12     sprintf(buffer, "newline:\n tab:\t backslash:\\ quote:\" apostrophe:'");
 13     if (buffer[8] == '\n' && buffer[14] == '\t' && buffer[26] == '\\' && buffer[34] == '"' && buffer[47] == '\'') {
 14-        printf("[PASS] Basic escape sequences work correctly\n");
 15+        printf("PASS: Basic escapes\n");
 16         passed++;
 17     } else {
 18-        printf("[FAIL] Basic escape sequences failed\n");
 19+        printf("FAIL: Basic escapes\n");
 20     }
 21 
 22-    // Test 2: Octal escape sequence \000 (NULL)
 23     total++;
 24     sprintf(buffer, "null:\000test");
 25     if (buffer[5] == 0) {
 26-        printf("[PASS] Octal \\000 (NULL) escape sequence works\n");
 27+        printf("PASS: Octal \\000 (NULL)\n");
 28         passed++;
 29     } else {
 30-        printf("[FAIL] Octal \\000 escape sequence failed\n");
 31+        printf("FAIL: Octal \\000\n");
 32     }
 33 
 34-    // Test 3: Octal escape sequence \033 (ESC for ANSI)
 35     total++;
 36     sprintf(buffer, "esc:\033test");
 37-    if (buffer[4] == 27) {  // ASCII 27 = ESC
 38-        printf("[PASS] Octal \\033 (ESC) escape sequence works\n");
 39+    if (buffer[4] == 27) {
 40+        printf("PASS: Octal \\033 (ESC)\n");
 41         passed++;
 42     } else {
 43-        printf("[FAIL] Octal \\033 escape sequence failed (got %d, expected 27)\n", buffer[4]);
 44+        printf("FAIL: Octal \\033 (got %d, expected 27)\n", buffer[4]);
 45     }
 46 
 47-    // Test 4: Octal escape sequence \101 (ASCII 'A')
 48     total++;
 49     sprintf(buffer, "A:\101test");
 50-    if (buffer[2] == 65) {  // ASCII 65 = 'A'
 51-        printf("[PASS] Octal \\101 (ASCII A) escape sequence works\n");
 52+    if (buffer[2] == 65) {
 53+        printf("PASS: Octal \\101 (ASCII A)\n");
 54         passed++;
 55     } else {
 56-        printf("[FAIL] Octal \\101 escape sequence failed (got %d, expected 65)\n", buffer[2]);
 57+        printf("FAIL: Octal \\101 (got %d, expected 65)\n", buffer[2]);
 58     }
 59 
 60-    // Test 5: Octal escape sequence \377 (max value 255)
 61-    // NOTE: This test currently fails due to UTF-8 encoding issues in string literals
 62-    // The value 255 gets UTF-8 encoded as bytes 195,191 instead of a single byte 255
 63     total++;
 64     sprintf(buffer, "max:\377test");
 65     if (buffer[4] == 255) {
 66-        printf("[PASS] Octal \\377 (255) escape sequence works\n");
 67+        printf("PASS: Octal \\377 (255)\n");
 68         passed++;
 69     } else {
 70-        printf("[FAIL] Octal \\377 escape sequence failed (got %d, expected 255) - UTF-8 encoding issue\n", buffer[4]);
 71+        printf("FAIL: Octal \\377 (got %d, expected 255) - UTF-8 issue\n", buffer[4]);
 72     }
 73 
 74-    // Test 6: Single digit octal \007 (BEL) - Go-style 3 digits
 75     total++;
 76     sprintf(buffer, "bel:\007test");
 77     if (buffer[4] == 7) {
 78-        printf("[PASS] Go-style octal \\007 (BEL) works\n");
 79+        printf("PASS: Go-style \\007 (BEL)\n");
 80         passed++;
 81     } else {
 82-        printf("[FAIL] Go-style octal \\007 failed (got %d, expected 7)\n", buffer[4]);
 83+        printf("FAIL: Go-style \\007 (got %d, expected 7)\n", buffer[4]);
 84     }
 85 
 86-    // Test 7: Two digit octal \012 (newline) - Go-style 3 digits
 87     total++;
 88     sprintf(buffer, "lf:\012test");
 89-    if (buffer[3] == 10) {  // ASCII 10 = LF
 90-        printf("[PASS] Go-style octal \\012 (LF) works\n");
 91+    if (buffer[3] == 10) {
 92+        printf("PASS: Go-style \\012 (LF)\n");
 93         passed++;
 94     } else {
 95-        printf("[FAIL] Go-style octal \\012 failed (got %d, expected 10)\n", buffer[3]);
 96+        printf("FAIL: Go-style \\012 (got %d, expected 10)\n", buffer[3]);
 97     }
 98 
 99-    // Test 8: ANSI color sequence (real world usage)
100+    printf("\nANSI color:\n");
101     total++;
102-    printf("\n--- Testing ANSI Color Sequences ---\n");
103     sprintf(buffer, "\033[31mRED\033[0m");
104     if (buffer[0] == 27 && buffer[1] == '[' && buffer[2] == '3' && buffer[3] == '1' && buffer[4] == 'm') {
105-        printf("[PASS] ANSI color sequence parsed correctly: ");
106-        printf(buffer);  // This should display "RED" in red if terminal supports it
107+        printf("PASS: ANSI color sequence: ");
108+        printf(buffer);
109         printf("\n");
110         passed++;
111     } else {
112-        printf("[FAIL] ANSI color sequence failed\n");
113+        printf("FAIL: ANSI color sequence\n");
114     }
115 
116-    // Test 9: Mixed escape sequences
117     total++;
118     sprintf(buffer, "Line1\nLine2\t\033[32mGreen\033[0m\\\042End\042");
119     if (buffer[5] == '\n' && buffer[11] == '\t' && buffer[12] == 27 && buffer[26] == '\\' && buffer[27] == '"') {
120-        printf("[PASS] Mixed escape sequences work correctly\n");
121+        printf("PASS: Mixed escapes\n");
122         passed++;
123     } else {
124-        printf("[FAIL] Mixed escape sequences failed\n");
125+        printf("FAIL: Mixed escapes\n");
126     }
127 
128-    // Test 10: Character literals with octal escapes - Go-style
129     total++;
130     auto esc_char = '\033';
131     auto null_char = '\000';
132     if (esc_char == 27 && null_char == 0) {
133-        printf("[PASS] Character literals with Go-style octal escapes work\n");
134+        printf("PASS: Character literals with Go-style octal\n");
135         passed++;
136     } else {
137-        printf("[FAIL] Character literals with Go-style octal escapes failed\n");
138+        printf("FAIL: Character literals with Go-style octal\n");
139     }
140 
141-    // Test 11: Go-style octal sequences (exactly 3 digits)
142     total++;
143-    sprintf(buffer, "a\000b\000c\000\060d");  // \000 = null, \060 = '0'
144+    sprintf(buffer, "a\000b\000c\000\060d");
145     if (buffer[1] == 0 && buffer[3] == 0 && buffer[5] == 0 && buffer[6] == '0') {
146-        printf("[PASS] Go-style 3-digit octal sequences work\n");
147+        printf("PASS: Go-style 3-digit octal\n");
148         passed++;
149     } else {
150-        printf("[FAIL] Go-style 3-digit octal sequences failed\n");
151+        printf("FAIL: Go-style 3-digit octal\n");
152     }
153 
154-    // Test 12: Boundary octal values
155     total++;
156-    sprintf(buffer, "\001\010\077\100\177");  // 1, 8, 63, 64, 127
157+    sprintf(buffer, "\001\010\077\100\177");
158     if (buffer[0] == 1 && buffer[1] == 8 && buffer[2] == 63 && buffer[3] == 64 && buffer[4] == 127) {
159-        printf("[PASS] Boundary octal values work correctly\n");
160+        printf("PASS: Boundary octal values\n");
161         passed++;
162     } else {
163-        printf("[FAIL] Boundary octal values failed\n");
164+        printf("FAIL: Boundary octal values\n");
165     }
166 
167-    // Final results
168-    printf("\n=== Test Results ===\n");
169-    printf("Passed: %d/%d tests\n", passed, total);
170+    printf("\nResults: %d/%d tests passed\n", passed, total);
171     if (passed == total) {
172-        printf("All escape sequence tests PASSED!\n");
173+        printf("All tests passed!\n");
174         return (0);
175     } else {
176-        printf("Some tests FAILED. Parser may have issues.\n");
177+        printf("Some tests failed.\n");
178         return (1);
179     }
180 }
D tests/float32_arithmetic.bx
+0, -23
 1@@ -1,23 +0,0 @@
 2-extrn printf;
 3-
 4-int main() {
 5-   float32 x, y, z;
 6-   
 7-   // Try accessing them before any assignment to see uninitialized values
 8-   printf("Initial: x = %.3f, y = %.3f, z = %.3f\n", x, y, z);
 9-   
10-   // Assign values
11-   x = 1.25;
12-   y = 2.75;
13-   z = x + y;  // This should be 4.0
14-   
15-   printf("After assignment: x = %.3f, y = %.3f, z = %.3f\n", x, y, z);
16-   
17-   // Try some arithmetic
18-   x = x * 2.0;  // Should be 2.5
19-   y = y / 2.0;  // Should be 1.375
20-   
21-   printf("After arithmetic: x = %.3f, y = %.3f, z = %.3f\n", x, y, z);
22-   
23-   return (0);
24-}
D tests/float32_debug.bx
+0, -14
 1@@ -1,14 +0,0 @@
 2-extrn printf;
 3-
 4-int main() {
 5-   float32 x, y, z;
 6-   x = 1.25;
 7-   y = 2.75;
 8-   printf("x type: %s\n", typeof(x));
 9-   printf("y type: %s\n", typeof(y));
10-   printf("x + y type: %s\n", typeof(x + y));
11-   z = x + y;
12-   printf("z type: %s\n", typeof(z));
13-   printf("z = %.3f\n", z);
14-   return (0);
15-}
M tests/float32_issue.bx
+5, -8
 1@@ -3,18 +3,15 @@ extrn printf;
 2 int main() {
 3    float32 x, y;
 4    printf("Before: x = %.3f, y = %.3f\n", x, y);
 5-   
 6-   // Perform some float operations first
 7+
 8    float a = 8.50;
 9    float b = 7.50;
10    printf("After float ops: a = %.3f, b = %.3f\n", a, b);
11-   
12-   // Now assign to float32 variables  
13+
14    x = 1.25;
15    y = 2.75;
16    printf("After assignment: x = %.3f, y = %.3f\n", x, y);
17-   
18-   // Check if they maintain their values
19-   printf("Final check: x = %.3f, y = %.3f\n", x, y);
20+
21+   printf("result: x = %.3f, y = %.3f\n", x, y);
22    return (0);
23-}
24+}
D tests/float32_uninitialized.bx
+0, -10
 1@@ -1,10 +0,0 @@
 2-extrn printf;
 3-
 4-int main() {
 5-   float32 x, y;  // Declare but do not initialize
 6-   printf("Before assignment: x = %.3f, y = %.3f\n", x, y);
 7-   x = 1.25;
 8-   y = 2.75;
 9-   printf("After assignment: x = %.3f, y = %.3f\n", x, y);
10-   return (0);
11-}
D tests/float_arrays.bx
+0, -16
 1@@ -1,16 +0,0 @@
 2-extrn printf;
 3-
 4-main() {
 5-   float float_array[3];
 6-   float32 float32_array[3];
 7-
 8-   float_array[0], float32_array[0] = 1.1, 1.25;
 9-   float_array[1], float32_array[1] = 2.2, 2.75;
10-   float_array[2], float32_array[2] = 3.3, 3.125;
11-
12-   printf("float[0]: %g, float32[0]: %g\n", float_array[0], float32_array[0]);
13-   printf("float[1]: %g, float32[1]: %g\n", float_array[1], float32_array[1]);
14-   printf("float[2]: %g, float32[2]: %g\n", float_array[2], float32_array[2]);
15-
16-   return(0);
17-}
D tests/float_mixed_types.bx
+0, -21
 1@@ -1,21 +0,0 @@
 2-extrn printf;
 3-
 4-int main() {
 5-   // Test same float type combinations  
 6-   float32 x = 1.5;
 7-   float32 y = 2.5;
 8-   
 9-   printf("x (float32): %.3f\n", x);
10-   printf("y (float32): %.3f\n", y); 
11-   
12-   // Same type operations should preserve type
13-   printf("x + y (float32 + float32): %.3f\n", x + y);  // Should be float32
14-   printf("x * y (float32 * float32): %.3f\n", x * y);  // Should be float32
15-   printf("x / y (float32 / float32): %.3f\n", x / y);  // Should be float32
16-   
17-   float64 a = 3.5;
18-   float64 b = 4.5;
19-   printf("a + b (float64 + float64): %.3f\n", a + b);  // Should be float64
20-   
21-   return (0);
22-}
D tests/floats2.bx
+0, -8
1@@ -1,8 +0,0 @@
2-extrn printf;
3-main() {
4-    printf("[%.3f, %.3f, %.3f]\n", 1.25, 2.75, 3.125);
5-    printf("[%s, %s, %s]\n", typeof(1.25), typeof(2.75), typeof(3.125));
6-    printf("[float32(%.3f), float32(%.3f), float32(%.3f)]\n", float32(1.25), float32(2.75), float32(3.125));
7-    printf("[%s, %s, %s]\n", typeof(float32(1.25)), typeof(float32(2.75)), typeof(float32(3.125)));
8-}
9-
R tests/multi_assign.b => tests/multi_assign.bx
+14, -5
 1@@ -1,4 +1,3 @@
 2-// Test multi-assignment functionality
 3 assert_equal(actual, expected, message) {
 4     extrn printf, abort;
 5     printf("%s: ", message);
 6@@ -13,31 +12,41 @@ assert_equal(actual, expected, message) {
 7 main() {
 8     extrn assert_equal;
 9     
10-    // Test 1: Simple two-variable assignment
11     auto a, b;
12     a, b = 10, 20;
13     assert_equal(a, 10, "a, b = 10, 20; a == 10");
14     assert_equal(b, 20, "a, b = 10, 20; b == 20");
15     
16-    // Test 2: Three-variable assignment
17     auto x, y, z;
18     x, y, z = 100, 200, 300;
19     assert_equal(x, 100, "x, y, z = 100, 200, 300; x == 100");
20     assert_equal(y, 200, "x, y, z = 100, 200, 300; y == 200");
21     assert_equal(z, 300, "x, y, z = 100, 200, 300; z == 300");
22     
23-    // Test 3: Array element assignment
24     auto arr1 3, arr2 3;
25     arr1[0], arr2[0] = 50, 60;
26     assert_equal(arr1[0], 50, "arr1[0], arr2[0] = 50, 60; arr1[0] == 50");
27     assert_equal(arr2[0], 60, "arr1[0], arr2[0] = 50, 60; arr2[0] == 60");
28     
29-    // Test 4: Mixed lvalue types
30     auto p, q, mixed 2;
31     p, mixed[1], q = 1000, 2000, 3000;
32     assert_equal(p, 1000, "p, mixed[1], q = 1000, 2000, 3000; p == 1000");
33     assert_equal(mixed[1], 2000, "p, mixed[1], q = 1000, 2000, 3000; mixed[1] == 2000");
34     assert_equal(q, 3000, "p, mixed[1], q = 1000, 2000, 3000; q == 3000");
35     
36+    int int_array[3];
37+    int other_array[3];
38+    
39+    int_array[0], other_array[0] = 42, 84;
40+    int_array[1], other_array[1] = 123, 246;
41+    int_array[2], other_array[2] = 999, 1998;
42+    
43+    assert_equal(int_array[0], 42, "int_array[0], other_array[0] = 42, 84; int_array[0] == 42");
44+    assert_equal(other_array[0], 84, "int_array[0], other_array[0] = 42, 84; other_array[0] == 84");
45+    assert_equal(int_array[1], 123, "int_array[1], other_array[1] = 123, 246; int_array[1] == 123");
46+    assert_equal(other_array[1], 246, "int_array[1], other_array[1] = 123, 246; other_array[1] == 246");
47+    assert_equal(int_array[2], 999, "int_array[2], other_array[2] = 999, 1998; int_array[2] == 999");
48+    assert_equal(other_array[2], 1998, "int_array[2], other_array[2] = 999, 1998; other_array[2] == 1998");
49+    
50     return(0);
51 }
D tests/multi_assign_typed.bx
+0, -32
 1@@ -1,32 +0,0 @@
 2-// Test multi-assignment functionality with Bx typed syntax
 3-assert_equal(actual, expected, message) {
 4-    extrn printf, abort;
 5-    printf("%s: ", message);
 6-    if (actual != expected) {
 7-        printf("FAIL\n");
 8-        abort();
 9-    } else {
10-        printf("OK\n");
11-    }
12-}
13-
14-main() {
15-    extrn assert_equal;
16-    
17-    // Test with typed variables and arrays (Bx style)
18-    int int_array[3];
19-    int other_array[3];
20-    
21-    int_array[0], other_array[0] = 42, 84;
22-    int_array[1], other_array[1] = 123, 246;
23-    int_array[2], other_array[2] = 999, 1998;
24-    
25-    assert_equal(int_array[0], 42, "int_array[0], other_array[0] = 42, 84; int_array[0] == 42");
26-    assert_equal(other_array[0], 84, "int_array[0], other_array[0] = 42, 84; other_array[0] == 84");
27-    assert_equal(int_array[1], 123, "int_array[1], other_array[1] = 123, 246; int_array[1] == 123");
28-    assert_equal(other_array[1], 246, "int_array[1], other_array[1] = 123, 246; other_array[1] == 246");
29-    assert_equal(int_array[2], 999, "int_array[2], other_array[2] = 999, 1998; int_array[2] == 999");
30-    assert_equal(other_array[2], 1998, "int_array[2], other_array[2] = 999, 1998; other_array[2] == 1998");
31-    
32-    return(0);
33-}
D tests/simple_float32.bx
+0, -8
1@@ -1,8 +0,0 @@
2-extrn printf;
3-
4-int main() {
5-   float32 x;
6-   x = 1.25;
7-   printf("x = %.3f\n", x);
8-   return (0);
9-}
A tests/typeof.bx
+78, -0
 1@@ -0,0 +1,78 @@
 2+extrn printf;
 3+
 4+type struct Point {
 5+    x int;
 6+    y int;
 7+};
 8+
 9+type enum Color {
10+    RED,
11+    GREEN,
12+    BLUE
13+};
14+
15+void testFunc(i int, f float) {
16+    printf("param int: %s\n", typeof(i));
17+    printf("param float: %s\n", typeof(f));
18+}
19+
20+float returnFloat() {
21+    return (2.5);
22+}
23+
24+main() {
25+    printf("Basic types:\n");
26+    
27+    int i = 42;
28+    uint ui = 42;
29+    float f = 3.14;
30+    bool b = 1;
31+    byte by = 65;
32+    printf("int: %s, uint: %s, float: %s, bool: %s, byte: %s\n", 
33+           typeof(i), typeof(ui), typeof(f), typeof(b), typeof(by));
34+
35+    printf("\nLiterals:\n");
36+    printf("42: %s, 3.14: %s, \"hello\": %s\n", 
37+           typeof(42), typeof(3.14), typeof("hello"));
38+    
39+    auto auto_int = 42;
40+    auto auto_float = 3.14;
41+    printf("auto int: %s, auto float: %s\n", typeof(auto_int), typeof(auto_float));
42+
43+    printf("\nPointers and arrays:\n");
44+    auto ptr = &i;
45+    int arr[3];
46+    arr[0] = 10;
47+    printf("int ptr: %s, array: %s, element: %s\n", 
48+           typeof(ptr), typeof(arr), typeof(arr[0]));
49+
50+    printf("\nStructs and enums:\n");
51+    Point p;
52+    p.x = 10;
53+    Color color = RED;
54+    printf("struct: %s, member: %s, enum: %s\n", 
55+           typeof(p), typeof(p.x), typeof(color));
56+
57+    printf("\nExpressions:\n");
58+    printf("i + i: %s, f + f: %s, float(i) + f: %s\n", 
59+           typeof(i + i), typeof(f + f), typeof(float(i) + f));
60+    printf("i > 0: %s\n", typeof(i > 0));
61+
62+    printf("\nControl flow:\n");
63+    if (i > 0) {
64+        printf("in if: %s\n", typeof(i));
65+    }
66+    
67+    auto counter = 0;
68+    while (counter < 2) {
69+        printf("in loop: %s\n", typeof(counter));
70+        counter++;
71+    }
72+
73+    printf("\nFunction calls:\n");
74+    testFunc(42, 3.14);
75+    auto ret = returnFloat();
76+    printf("returned: %s\n", typeof(ret));
77+
78+    return(0);
79+}
D tests/typeof_basic.bx
+0, -101
  1@@ -1,101 +0,0 @@
  2-// Comprehensive tests for typeof and literal type inference
  3-extrn printf;
  4-
  5-main() {
  6-    printf("=== Basic Type Tests ===\n");
  7-
  8-    // Primitive types
  9-    int i;
 10-    i = 42;
 11-    printf("int: %s\n", typeof(i));
 12-
 13-    uint ui;
 14-    ui = 42;
 15-    printf("uint: %s\n", typeof(ui));
 16-
 17-    int8 i8;
 18-    i8 = 42;
 19-    printf("int8: %s\n", typeof(i8));
 20-
 21-    uint8 ui8;
 22-    ui8 = 42;
 23-    printf("uint8: %s\n", typeof(ui8));
 24-
 25-    int16 i16;
 26-    i16 = 42;
 27-    printf("int16: %s\n", typeof(i16));
 28-
 29-    uint16 ui16;
 30-    ui16 = 42;
 31-    printf("uint16: %s\n", typeof(ui16));
 32-
 33-    int32 i32;
 34-    i32 = 42;
 35-    printf("int32: %s\n", typeof(i32));
 36-
 37-    uint32 ui32;
 38-    ui32 = 42;
 39-    printf("uint32: %s\n", typeof(ui32));
 40-
 41-    int64 i64;
 42-    i64 = 42;
 43-    printf("int64: %s\n", typeof(i64));
 44-
 45-    uint64 ui64;
 46-    ui64 = 42;
 47-    printf("uint64: %s\n", typeof(ui64));
 48-
 49-    // Float types
 50-    float f;
 51-    f = 3.14;
 52-    printf("float: %s\n", typeof(f));
 53-
 54-    float32 f32;
 55-    f32 = 3.14;
 56-    printf("float32: %s\n", typeof(f32));
 57-
 58-    float64 f64;
 59-    f64 = 3.14;
 60-    printf("float64: %s\n", typeof(f64));
 61-
 62-    // Other types
 63-    bool b;
 64-    b = 1;
 65-    printf("bool: %s\n", typeof(b));
 66-
 67-    byte by;
 68-    by = 65;
 69-    printf("byte: %s\n", typeof(by));
 70-
 71-    printf("\n=== Literal Types ===\n");
 72-
 73-    // Integer literals should default to int
 74-    printf("42: %s\n", typeof(42));
 75-    printf("0x42: %s\n", typeof(0x42));
 76-    printf("0755: %s\n", typeof(0755));
 77-
 78-    // Float literals should default to float
 79-    printf("3.14: %s\n", typeof(3.14));
 80-    printf("0.5: %s\n", typeof(0.5));
 81-    printf("1.0e-5: %s\n", typeof(1.0e-5));
 82-
 83-    // String literals
 84-    printf("\"hello\": %s\n", typeof("hello"));
 85-
 86-    // Nil
 87-    printf("nil: %s\n", typeof(nil));
 88-
 89-    printf("\n=== Auto Variables ===\n");
 90-
 91-    // Auto variables with literals
 92-    auto auto_int = 42;
 93-    printf("auto int: %s\n", typeof(auto_int));
 94-
 95-    auto auto_float = 3.14;
 96-    printf("auto float: %s\n", typeof(auto_float));
 97-
 98-    auto auto_string = "hello";
 99-    printf("auto string: %s\n", typeof(auto_string));
100-
101-    return(0);
102-}
D tests/typeof_complex.bx
+0, -120
  1@@ -1,120 +0,0 @@
  2-// Tests for typeof with pointers, arrays, and structs
  3-extrn printf;
  4-
  5-type struct Point {
  6-    x int;
  7-    y int;
  8-};
  9-
 10-type struct FloatPoint {
 11-    x float32;
 12-    y float32;
 13-};
 14-
 15-type enum Color {
 16-    RED,
 17-    GREEN,
 18-    BLUE
 19-};
 20-
 21-void testPointers() {
 22-    printf("=== Pointer Types ===\n");
 23-    
 24-    int value;
 25-    value = 42;
 26-    printf("int value: %s\n", typeof(value));
 27-    
 28-    auto ptr = &value;
 29-    printf("int pointer: %s\n", typeof(ptr));
 30-    
 31-    auto deref = *ptr;
 32-    printf("dereferenced: %s\n", typeof(deref));
 33-    
 34-    // Different pointer types
 35-    float32 float_val;
 36-    float_val = 3.14;
 37-    auto float_ptr = &float_val;
 38-    printf("float32 pointer: %s\n", typeof(float_ptr));
 39-}
 40-
 41-void testArrays() {
 42-    printf("\n=== Array Types ===\n");
 43-    
 44-    int int_array[5];
 45-    printf("int array: %s\n", typeof(int_array));
 46-    
 47-    float32 float_array[3];
 48-    printf("float32 array: %s\n", typeof(float_array));
 49-    
 50-    // Array element access
 51-    int_array[0] = 10;
 52-    printf("array element: %s\n", typeof(int_array[0]));
 53-    
 54-    float_array[0] = 1.5;
 55-    printf("float array element: %s\n", typeof(float_array[0]));
 56-}
 57-
 58-void testStructs() {
 59-    printf("\n=== Struct Types ===\n");
 60-    
 61-    Point p;
 62-    printf("Point struct: %s\n", typeof(p));
 63-    
 64-    p.x = 10;
 65-    p.y = 20;
 66-    printf("struct member x: %s\n", typeof(p.x));
 67-    printf("struct member y: %s\n", typeof(p.y));
 68-    
 69-    FloatPoint fp;
 70-    fp.x = 1.5;
 71-    fp.y = 2.5;
 72-    printf("FloatPoint struct: %s\n", typeof(fp));
 73-    printf("float struct member: %s\n", typeof(fp.x));
 74-    
 75-    // Struct pointer
 76-    auto struct_ptr = &p;
 77-    printf("struct pointer: %s\n", typeof(struct_ptr));
 78-}
 79-
 80-void testEnums() {
 81-    printf("\n=== Enum Types ===\n");
 82-    
 83-    Color color;
 84-    color = RED;
 85-    printf("enum Color: %s\n", typeof(color));
 86-    
 87-    auto enum_val = BLUE;
 88-    printf("enum value: %s\n", typeof(enum_val));
 89-}
 90-
 91-void testComplexExpressions() {
 92-    printf("\n=== Complex Expressions ===\n");
 93-    
 94-    auto a = 10;
 95-    auto b = 20;
 96-    
 97-    // Arithmetic expressions
 98-    printf("a + b: %s\n", typeof(a + b));
 99-    printf("a * b: %s\n", typeof(a * b));
100-    
101-    auto x = 1.5;
102-    auto y = 2.5;
103-    printf("x + y: %s\n", typeof(x + y));
104-    
105-    // Mixed type expressions
106-    printf("a + x: %s\n", typeof(a + x));
107-    
108-    // Comparison expressions
109-    printf("a > b: %s\n", typeof(a > b));
110-    printf("x < y: %s\n", typeof(x < y));
111-}
112-
113-main() {
114-    testPointers();
115-    testArrays();
116-    testStructs();
117-    testEnums();
118-    testComplexExpressions();
119-    
120-    return(0);
121-}
D tests/typeof_control_flow.bx
+0, -77
 1@@ -1,77 +0,0 @@
 2-// Tests for typeof in control flow contexts (if, switch/case)
 3-extrn printf;
 4-
 5-void testIf() {
 6-    printf("=== If Statement Context ===\n");
 7-    
 8-    auto x = 42;
 9-    auto y = 3.14;
10-    
11-    if (x > 0) {
12-        printf("x is positive: %s\n", typeof(x));
13-        
14-        if (y > 3.0) {
15-            printf("y is > 3.0: %s\n", typeof(y));
16-        }
17-    }
18-    
19-    // Test typeof in condition expressions
20-    auto condition_int = 1;
21-    auto condition_float = 0.0;
22-    
23-    if (condition_int) {
24-        printf("condition int: %s\n", typeof(condition_int));
25-    }
26-    
27-    if (!condition_float) {
28-        printf("condition float: %s\n", typeof(condition_float));
29-    }
30-}
31-
32-void testSwitch() {
33-    printf("\n=== Switch/Case Context ===\n");
34-    
35-    auto value = 2;
36-    printf("switch value: %s\n", typeof(value));
37-    
38-    switch (value) {
39-        case 1:
40-            printf("case 1: %s\n", typeof(value));
41-            break;
42-        case 2:
43-            printf("case 2: %s\n", typeof(value));
44-            break;
45-        default:
46-            printf("default: %s\n", typeof(value));
47-            break;
48-    }
49-    
50-    // Test with different types
51-    auto float_value = 1.5;
52-    printf("float switch value: %s\n", typeof(float_value));
53-    
54-    // Note: Bx may not support float in switch, but we can test the type
55-    if (float_value > 1.0) {
56-        printf("float > 1.0: %s\n", typeof(float_value));
57-    }
58-}
59-
60-void testLoop() {
61-    printf("\n=== Loop Context ===\n");
62-    
63-    auto counter = 0;
64-    printf("loop counter: %s\n", typeof(counter));
65-    
66-    while (counter < 3) {
67-        printf("in loop [%d]: %s\n", counter, typeof(counter));
68-        counter = counter + 1;
69-    }
70-}
71-
72-main() {
73-    testIf();
74-    testSwitch();
75-    testLoop();
76-    
77-    return(0);
78-}
D tests/typeof_functions.bx
+0, -53
 1@@ -1,53 +0,0 @@
 2-// Tests for typeof in function parameter contexts
 3-extrn printf;
 4-
 5-// Test function with various parameter types
 6-void testFunc(i int, f32 float32, u8 uint8, f64 float64) {
 7-    printf("In testFunc:\n");
 8-    printf("  param int: %s\n", typeof(i));
 9-    printf("  param float32: %s\n", typeof(f32));
10-    printf("  param uint8: %s\n", typeof(u8)); 
11-    printf("  param float64: %s\n", typeof(f64));
12-}
13-
14-// Test function calls with literals - verify type coercion
15-void testLiteralCoercion() {
16-    printf("\n=== Function Parameter Type Coercion ===\n");
17-    
18-    // Call with literals - should get coerced to parameter types
19-    testFunc(42, 3.14, 255, 2.718);
20-    
21-    // Test in assignment context
22-    printf("\n=== Assignment Context ===\n");
23-    
24-    float32 assigned_literal;
25-    assigned_literal = 0.5;  // literal float should be coerced to float32
26-    printf("assigned literal to float32: %s\n", typeof(assigned_literal));
27-    
28-    int32 assigned_int;  
29-    assigned_int = 100;  // literal int should be coerced to int32
30-    printf("assigned literal to int32: %s\n", typeof(assigned_int));
31-}
32-
33-// Test return types
34-float32 returnFloat32() {
35-    return (2.5);  // literal should be coerced to float32
36-}
37-
38-int16 returnInt16() {
39-    return (42);  // literal should be coerced to int16  
40-}
41-
42-main() {
43-    testLiteralCoercion();
44-    
45-    printf("\n=== Return Type Context ===\n");
46-    
47-    auto ret_f32 = returnFloat32();
48-    printf("returned float32: %s\n", typeof(ret_f32));
49-    
50-    auto ret_i16 = returnInt16();
51-    printf("returned int16: %s\n", typeof(ret_i16));
52-    
53-    return(0);
54-}
D tests/typeof_functions_simple.bx
+0, -51
 1@@ -1,51 +0,0 @@
 2-// Tests for typeof in function parameter contexts
 3-extrn printf;
 4-
 5-// Test function with simple parameters
 6-void testFunc(i int, f float) {
 7-    printf("In testFunc:\n");
 8-    printf("  param int: %s\n", typeof(i));
 9-    printf("  param float: %s\n", typeof(f));
10-}
11-
12-// Test function calls with literals - verify type coercion
13-void testLiteralCoercion() {
14-    printf("\n=== Function Parameter Type Coercion ===\n");
15-    
16-    // Call with literals - should get coerced to parameter types
17-    testFunc(42, 3.14);
18-    
19-    // Test in assignment context
20-    printf("\n=== Assignment Context ===\n");
21-    
22-    float assigned_literal;
23-    assigned_literal = 0.5;  // literal float should be coerced to float
24-    printf("assigned literal to float: %s\n", typeof(assigned_literal));
25-    
26-    int assigned_int;  
27-    assigned_int = 100;  // literal int should be coerced to int
28-    printf("assigned literal to int: %s\n", typeof(assigned_int));
29-}
30-
31-// Test return types
32-float returnFloat() {
33-    return (2.5);  // literal should be coerced to float
34-}
35-
36-int returnInt() {
37-    return (42);  // literal should be coerced to int  
38-}
39-
40-main() {
41-    testLiteralCoercion();
42-    
43-    printf("\n=== Return Type Context ===\n");
44-    
45-    auto ret_f = returnFloat();
46-    printf("returned float: %s\n", typeof(ret_f));
47-    
48-    auto ret_i = returnInt();
49-    printf("returned int: %s\n", typeof(ret_i));
50-    
51-    return(0);
52-}
D tests/typeof_literals.bx
+0, -95
 1@@ -1,95 +0,0 @@
 2-// Tests for typeof with array and struct literals
 3-extrn printf;
 4-
 5-type struct Point {
 6-    x int;
 7-    y int;
 8-};
 9-
10-type struct FloatPoint {
11-    x float32;
12-    y float32;
13-};
14-
15-void testStructLiterals() {
16-    printf("=== Struct Literal Types ===\n");
17-    
18-    // Named struct literals
19-    auto p1 = Point{x: 10, y: 20};
20-    printf("Point literal: %s\n", typeof(p1));
21-    
22-    auto p2 = Point{5, 15};
23-    printf("Point positional literal: %s\n", typeof(p2));
24-    
25-    auto fp = FloatPoint{x: 1.5, y: 2.5};
26-    printf("FloatPoint literal: %s\n", typeof(fp));
27-    
28-    // Nested struct access
29-    printf("Point member x: %s\n", typeof(p1.x));
30-    printf("FloatPoint member x: %s\n", typeof(fp.x));
31-}
32-
33-void testArrayLiterals() {
34-    printf("\n=== Array Literal Types ===\n");
35-    
36-    // Array literals with explicit types
37-    auto int_arr = []int{1, 2, 3, 4, 5};
38-    printf("int array literal: %s\n", typeof(int_arr));
39-    
40-    auto float_arr = []float32{1.1, 2.2, 3.3};
41-    printf("float32 array literal: %s\n", typeof(float_arr));
42-    
43-    auto str_arr = []string{"hello", "world"};
44-    printf("string array literal: %s\n", typeof(str_arr));
45-    
46-    // Array element access
47-    printf("int array element: %s\n", typeof(int_arr[0]));
48-    printf("float array element: %s\n", typeof(float_arr[0]));
49-    printf("string array element: %s\n", typeof(str_arr[0]));
50-}
51-
52-void testMixedLiterals() {
53-    printf("\n=== Mixed Literal Expressions ===\n");
54-    
55-    // Struct with array
56-    auto points = []Point{
57-        Point{x: 1, y: 2},
58-        Point{x: 3, y: 4}
59-    };
60-    printf("Point array: %s\n", typeof(points));
61-    printf("Point array element: %s\n", typeof(points[0]));
62-    
63-    // Array in function call context
64-    testArray([]float32{1.0, 2.0, 3.0});
65-}
66-
67-void testArray(float32 arr[]) {
68-    printf("Function array param: %s\n", typeof(arr));
69-    printf("Function array element: %s\n", typeof(arr[0]));
70-}
71-
72-void testLiteralAssignment() {
73-    printf("\n=== Literal Assignment Context ===\n");
74-    
75-    // Assign struct literal to typed variable
76-    Point p;
77-    p = Point{x: 100, y: 200};
78-    printf("Assigned struct: %s\n", typeof(p));
79-    
80-    // Assign array literal to typed variable  
81-    int numbers[3];
82-    // Note: Direct array literal assignment may not be supported
83-    numbers[0] = 1;
84-    numbers[1] = 2;
85-    numbers[2] = 3;
86-    printf("Assigned array: %s\n", typeof(numbers));
87-}
88-
89-main() {
90-    testStructLiterals();
91-    testArrayLiterals();
92-    testMixedLiterals();
93-    testLiteralAssignment();
94-    
95-    return(0);
96-}
D tests/typeof_literals_simple.bx
+0, -74
 1@@ -1,74 +0,0 @@
 2-// Tests for typeof with struct literals and simple expressions
 3-extrn printf;
 4-
 5-type struct Point {
 6-    x int;
 7-    y int;
 8-};
 9-
10-type struct FloatPoint {
11-    x float32;
12-    y float32;
13-};
14-
15-void testStructLiterals() {
16-    printf("=== Struct Literal Types ===\n");
17-    
18-    // Named struct literals
19-    auto p1 = Point{x: 10, y: 20};
20-    printf("Point literal: %s\n", typeof(p1));
21-    
22-    auto p2 = Point{5, 15};
23-    printf("Point positional literal: %s\n", typeof(p2));
24-    
25-    auto fp = FloatPoint{x: 1.5, y: 2.5};
26-    printf("FloatPoint literal: %s\n", typeof(fp));
27-    
28-    // Nested struct access
29-    printf("Point member x: %s\n", typeof(p1.x));
30-    printf("FloatPoint member x: %s\n", typeof(fp.x));
31-}
32-
33-void testLiteralAssignment() {
34-    printf("\n=== Literal Assignment Context ===\n");
35-    
36-    // Assign struct literal to typed variable
37-    Point p;
38-    p = Point{x: 100, y: 200};
39-    printf("Assigned struct: %s\n", typeof(p));
40-    
41-    // Simple array assignments
42-    int numbers[3];
43-    numbers[0] = 1;
44-    numbers[1] = 2;
45-    numbers[2] = 3;
46-    printf("Assigned array: %s\n", typeof(numbers));
47-    printf("Array element: %s\n", typeof(numbers[0]));
48-}
49-
50-void testMixedExpressions() {
51-    printf("\n=== Mixed Expressions ===\n");
52-    
53-    auto int_val = 42;
54-    auto float_val = 3.14;
55-    
56-    // Arithmetic with same types
57-    printf("int + int: %s\n", typeof(int_val + int_val));
58-    printf("float + float: %s\n", typeof(float_val + float_val));
59-    
60-    // Mixed arithmetic (should promote to float)
61-    printf("int + float: %s\n", typeof(int_val + float_val));
62-    printf("float * int: %s\n", typeof(float_val * int_val));
63-    
64-    // Comparison operations
65-    printf("int == int: %s\n", typeof(int_val == int_val));
66-    printf("float > int: %s\n", typeof(float_val > int_val));
67-}
68-
69-main() {
70-    testStructLiterals();
71-    testLiteralAssignment();
72-    testMixedExpressions();
73-    
74-    return(0);
75-}