Tests for new untyped conversions
This commit is contained in:
@@ -94,6 +94,18 @@ little_untyped_test :: ()
|
||||
if true;; pass
|
||||
cast_value1 := 32->S64
|
||||
cast_value2 := true->Bool
|
||||
value3 := !true
|
||||
value4 := !325252
|
||||
value5 := !42.42
|
||||
some_constant :: 10
|
||||
value6 := !some_constant
|
||||
var_not_const := 0
|
||||
value7 := some_constant + - -some_constant + +-32 + -var_not_const
|
||||
|
||||
|
||||
value3 = value3 + value4 + value5 + cast_value2 + value6
|
||||
cast_value1 += 1 + value7
|
||||
|
||||
|
||||
switch 4
|
||||
4;; OutputDebugStringA("4")
|
||||
@@ -104,6 +116,7 @@ little_untyped_test :: ()
|
||||
val := 4232.23
|
||||
thing: Any = val
|
||||
print(val)
|
||||
print(some_type)
|
||||
// print_array({125.23, 32})
|
||||
|
||||
assert(char_info.kind == Type_Info_Kind.CHAR)
|
||||
@@ -114,6 +127,7 @@ little_untyped_test :: ()
|
||||
|
||||
app_is_running := true
|
||||
window_procedure :: (hwnd: HWND, msg: UINT, wparam: WPARAM, lparam: LPARAM): LRESULT
|
||||
little_untyped_test()
|
||||
if msg == WM_DESTROY
|
||||
PostQuitMessage(0)
|
||||
app_is_running = false
|
||||
|
||||
@@ -1005,9 +1005,9 @@ resolve_expr(Ast_Expr *ast, Resolve_Flag flags, Ast_Type *compound_context){
|
||||
node->resolved_type = node->resolved_decl->type;
|
||||
|
||||
Operand result = operand(node->resolved_decl);
|
||||
if(result.is_const){
|
||||
if(result.is_const)
|
||||
rewrite_into_const(node, Ast_Atom, node->resolved_decl->value);
|
||||
}
|
||||
|
||||
return result;
|
||||
BREAK();
|
||||
}
|
||||
@@ -1030,6 +1030,9 @@ resolve_expr(Ast_Expr *ast, Resolve_Flag flags, Ast_Type *compound_context){
|
||||
type.type_val = type_slice(type.type_val, node);
|
||||
}
|
||||
|
||||
// If this is a type we want to rewrite that type
|
||||
// int o an integer constant which should be an id
|
||||
// of that type
|
||||
if(!is_flag_set(flags, RESOLVE_TYPESPEC)){
|
||||
rewrite_into_const(node, Ast_Array, type.value);
|
||||
}
|
||||
@@ -1050,13 +1053,14 @@ resolve_expr(Ast_Expr *ast, Resolve_Flag flags, Ast_Type *compound_context){
|
||||
CASE(INDEX, Index){
|
||||
Operand left = resolve_expr(node->expr, AST_CANT_BE_NULL);
|
||||
Operand index = resolve_expr(node->index, AST_CANT_BE_NULL);
|
||||
if(!is_int(index.type)){
|
||||
if(!is_int(index.type))
|
||||
compiler_error(node->pos, "Trying to index the array with invalid type, expected [Int] got instead %Q", typestring(index.type));
|
||||
}
|
||||
|
||||
node->index_original_type = left.type;
|
||||
|
||||
// @todo: type_architecture?
|
||||
// we only try to convert the index cause array can't be const
|
||||
// right now
|
||||
try_propagating_resolved_type_to_untyped_literals(node->index, type_s64);
|
||||
|
||||
if(!left.type)
|
||||
|
||||
Reference in New Issue
Block a user