[X] Char literals
- [ ] Properly checking binary operators
+ [X] Properly checking binary operators
- Shouldn't be able to add two structs/arrays together
[ ] Array literals
b32 type_is_struct(Type* type);
b32 type_is_bool(Type* type);
b32 type_is_integer(Type* type);
+b32 type_is_numeric(Type* type);
b32 type_results_in_void(Type* type);
#endif // #ifndef ONYX_TYPES
for i: 0, 8 do arr[i] = cast(i64) (i * i);
- walker := cast(^i64) arr;
+ walker := arr;
for _: 0, 8 {
- print_u64(cast(i64) *walker);
+ print_u64(*walker);
walker += 1;
}
print_bin(42l);
print_hex(42l);
- print_hex(cast(u64) #char "a");
+ for i: #char "a", #char "f" {
+ print_hex(cast(u64) i);
+ }
a := 12345;
|| binop->operation == Binary_Op_Bool_Or)
return check_binaryop_bool(binop);
+ if (!type_is_numeric(binop->left->type)) {
+ onyx_message_add(Msg_Type_Literal,
+ binop->token->pos,
+ "expected numeric type for left side of binary operator");
+ return 1;
+ }
+
+ if (!type_is_numeric(binop->right->type)) {
+ onyx_message_add(Msg_Type_Literal,
+ binop->token->pos,
+ "expected numeric type for right side of binary operator");
+ return 1;
+ }
+
if (type_is_pointer(binop->right->type)) {
onyx_message_add(Msg_Type_Literal,
binop->token->pos,
return type->Basic.kind >= Basic_Kind_I8 && type->Basic.kind <= Basic_Kind_U64;
}
+b32 type_is_numeric(Type* type) {
+ if (type->kind != Type_Kind_Basic) return 0;
+
+ return type->Basic.kind >= Basic_Kind_I8 && type->Basic.kind <= Basic_Kind_F64;
+}
+
b32 type_results_in_void(Type* type) {
return (type == NULL)
|| (type->kind == Type_Kind_Basic && type->Basic.kind == Basic_Kind_Void)