Fix type result on binary compuations.
This commit is contained in:
@@ -1435,9 +1435,13 @@ check_node :: (checker : *Semantic_Checker, node : *AST_Node) -> Type_Variable_H
|
||||
|
||||
variable, handle := new_type_variable(checker);
|
||||
lhs_type := from_handle(checker, lhs_var);
|
||||
variable.type = lhs_type.type;
|
||||
rhs_type := from_handle(checker, rhs_var);
|
||||
|
||||
|
||||
|
||||
variable.type = lhs_type.type;
|
||||
variable.typename = lhs_type.typename;
|
||||
variable.scope = lhs_type.scope;
|
||||
variable.scope = lhs_type.scope;
|
||||
variable.source_node = node;
|
||||
node.type_variable = handle;
|
||||
add_child(variable, lhs_var);
|
||||
@@ -1452,6 +1456,16 @@ check_node :: (checker : *Semantic_Checker, node : *AST_Node) -> Type_Variable_H
|
||||
type_mismatch(checker, node, node.children[1], lhs_var, rhs_var);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if lhs_type.type == .Struct {
|
||||
variable.type = lhs_type.type;
|
||||
variable.typename = lhs_type.typename;
|
||||
variable.scope = lhs_type.scope;
|
||||
} else if rhs_type.type == .Struct {
|
||||
variable.type = rhs_type.type;
|
||||
variable.typename = rhs_type.typename;
|
||||
variable.scope = rhs_type.scope;
|
||||
}
|
||||
}
|
||||
case .TOKEN_ASSIGN; {
|
||||
if !types_compatible(checker, lhs_var, rhs_var) {
|
||||
|
||||
44
Test.jai
44
Test.jai
@@ -372,8 +372,8 @@ run_test_new :: (file_path : string, stage_flags : Stage_Flags, results : *[..]R
|
||||
}
|
||||
}
|
||||
|
||||
run_test :: (test_case : Test_Case, results : *[..]Result, output_type : Output_Type = 0) {
|
||||
print("%Running test: %......", cyan(), test_case.path);
|
||||
run_test :: (test_case : Test_Case, results : *[..]Result, output_type : Output_Type = 0, builder : *String_Builder) {
|
||||
print_to_builder(builder, "%Running test: %......", cyan(), test_case.path);
|
||||
|
||||
// path 30
|
||||
// len 35
|
||||
@@ -387,7 +387,7 @@ run_test :: (test_case : Test_Case, results : *[..]Result, output_type : Output_
|
||||
len := 50;
|
||||
rest := len - test_case.path.count;
|
||||
for i: 0..rest {
|
||||
print(" ");
|
||||
append(builder, " ");
|
||||
}
|
||||
|
||||
run_test_new(test_case.path, test_case.stage_flags, results, output_type);
|
||||
@@ -416,7 +416,7 @@ run_test_suite :: (using suite : *Test_Suite, output_type : Output_Type = 0) {
|
||||
init_string_builder(*builder,, temp);
|
||||
|
||||
for test_case : test_cases {
|
||||
run_test(test_case, *suite.results, output_type);
|
||||
run_test(test_case, *suite.results, output_type, *builder);
|
||||
|
||||
for < suite.results {
|
||||
result := suite.results[it_index];
|
||||
@@ -432,7 +432,7 @@ run_test_suite :: (using suite : *Test_Suite, output_type : Output_Type = 0) {
|
||||
array_add(*failed_test_paths, .{ result.path, tprint("golden file not found for %", stage_to_string(result.stage)) });
|
||||
}
|
||||
}
|
||||
evaluate_result(result);
|
||||
evaluate_result(result, *builder);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
@@ -440,7 +440,7 @@ run_test_suite :: (using suite : *Test_Suite, output_type : Output_Type = 0) {
|
||||
|
||||
// print("\n");
|
||||
}
|
||||
print("\n");
|
||||
append(*builder, "\n");
|
||||
|
||||
if output_type == 0 {
|
||||
if failed_test_paths.count == 0 {
|
||||
@@ -530,42 +530,42 @@ stage_to_string :: (stage : Stage_Flags) -> string {
|
||||
}
|
||||
}
|
||||
|
||||
evaluate_result :: (result : Result) {
|
||||
evaluate_result :: (result : Result, builder : *String_Builder) {
|
||||
stage : string = stage_to_string(result.stage);
|
||||
|
||||
if #complete result.type == {
|
||||
case .File_Read_Failed; {
|
||||
print(" %", red());
|
||||
print("failed with File_Read_Failed\n");
|
||||
print_to_builder(builder, " %", red());
|
||||
print_to_builder(builder, "failed with File_Read_Failed\n");
|
||||
}
|
||||
case .Golden_File_Not_Found; {
|
||||
print(" %", red());
|
||||
print("failed with Golden File Not Found for stage %\n", stage);
|
||||
print_to_builder(builder, " %", red());
|
||||
print_to_builder(builder, "failed with Golden File Not Found for stage %\n", stage);
|
||||
}
|
||||
case .StdOut; {
|
||||
}
|
||||
case .Golden_Output; {
|
||||
print(" %", yellow());
|
||||
print("output new golden file at %\n", result.golden_path);
|
||||
print_to_builder(builder, " %", yellow());
|
||||
print_to_builder(builder, "output new golden file at %\n", result.golden_path);
|
||||
}
|
||||
case .Passed; {
|
||||
print(" %", green());
|
||||
print("passed %\n", stage);
|
||||
print_to_builder(builder, " %", green());
|
||||
print_to_builder(builder, "passed %\n", stage);
|
||||
}
|
||||
case .Failed; {
|
||||
print(" %", red());
|
||||
print("failed %\n", stage);
|
||||
print_to_builder(builder, " %", red());
|
||||
print_to_builder(builder, "failed %\n", stage);
|
||||
}
|
||||
}
|
||||
|
||||
if result.info_text.count > 0 {
|
||||
print("%", cyan());
|
||||
print("--- Info text ---\n");
|
||||
print("%", yellow());
|
||||
print("%\n", result.info_text);
|
||||
print_to_builder(builder, "%", cyan());
|
||||
print_to_builder(builder, "--- Info text ---\n");
|
||||
print_to_builder(builder, "%", yellow());
|
||||
print_to_builder(builder, "%\n", result.info_text);
|
||||
}
|
||||
|
||||
print("%", reset_color());
|
||||
print_to_builder(builder, "%", reset_color());
|
||||
}
|
||||
|
||||
main :: () {
|
||||
|
||||
@@ -1,4 +1,28 @@
|
||||
[1;37mtest/wrong_multiply.ink:4,34: [31merror: [37mType mismatch. Expected float got float2
|
||||
[1;37mtest/wrong_multiply.ink:4,18: [31merror: [37mProcedure call did not match any of the possible overloads for 'float4'
|
||||
[96m found:
|
||||
result : float4 = float4(1.0, foo * res, 0.0, 1.0);
|
||||
^^^^^^
|
||||
|
||||
[97m While matching argument 2 in function call.
|
||||
[96m result : float4 = float4(1.0, foo * res, 0.0, 1.0);
|
||||
^
|
||||
[97m Possible overloads:
|
||||
[96m foreign float4 :: (float, float, float, float) -> float4; (test/wrong_multiply.ink:86)
|
||||
[96m foreign float4 :: (float4) -> float4; (test/wrong_multiply.ink:87)
|
||||
[96m foreign float4 :: (float2, float2) -> float4; (test/wrong_multiply.ink:88)
|
||||
[96m foreign float4 :: (float2, float, float) -> float4; (test/wrong_multiply.ink:89)
|
||||
[96m foreign float4 :: (float, float2, float) -> float4; (test/wrong_multiply.ink:90)
|
||||
[96m foreign float4 :: (float, float2, float) -> float4; (test/wrong_multiply.ink:90)
|
||||
[96m foreign float4 :: (float, float, float2) -> float4; (test/wrong_multiply.ink:91)
|
||||
[96m foreign float4 :: (float, float, float2) -> float4; (test/wrong_multiply.ink:91)
|
||||
[96m foreign float4 :: (float3, float) -> float4; (test/wrong_multiply.ink:92)
|
||||
[96m foreign float4 :: (float3, float) -> float4; (test/wrong_multiply.ink:92)
|
||||
[96m foreign float4 :: (float, float3) -> float4; (test/wrong_multiply.ink:93)
|
||||
[96m foreign float4 :: (float, float3) -> float4; (test/wrong_multiply.ink:93)
|
||||
[96m foreign float4 :: (float) -> float4; (test/wrong_multiply.ink:94)
|
||||
[96m foreign float4 :: (float) -> float4; (test/wrong_multiply.ink:94)
|
||||
|
||||
[36m[37m[1;37mtest/wrong_multiply.ink:4,34: [31merror: [37mType mismatch. Expected float got float2
|
||||
[96m found:
|
||||
result : float4 = float4(1.0, foo * res, 0.0, 1.0);
|
||||
^
|
||||
@@ -6,6 +30,6 @@
|
||||
float
|
||||
|
||||
got:
|
||||
res : float2 = float2(2.0, 2.0)
|
||||
result : float4 = float4(1.0, foo * res, 0.0, 1.0);
|
||||
|
||||
[36m[37m
|
||||
Reference in New Issue
Block a user