diff options
-rw-r--r-- | gcc/rust/typecheck/rust-tyty.cc | 17 | ||||
-rw-r--r-- | gcc/testsuite/rust/compile/func3.rs | 6 |
2 files changed, 13 insertions, 10 deletions
diff --git a/gcc/rust/typecheck/rust-tyty.cc b/gcc/rust/typecheck/rust-tyty.cc index 64eab30..05e5942 100644 --- a/gcc/rust/typecheck/rust-tyty.cc +++ b/gcc/rust/typecheck/rust-tyty.cc @@ -2454,14 +2454,13 @@ TypeCheckCallExpr::visit (FnType &type) return; } - auto resolved_argument_type = argument_expr_tyty; - // it might be a varadic function if (i < type.num_params ()) { auto fnparam = type.param_at (i); - resolved_argument_type = fnparam.second->coerce (argument_expr_tyty); - if (argument_expr_tyty->get_kind () == TyTy::TypeKind::ERROR) + auto resolved_argument_type + = fnparam.second->coerce (argument_expr_tyty); + if (resolved_argument_type->get_kind () == TyTy::TypeKind::ERROR) { rust_error_at (argument->get_locus (), "Type Resolution failure on parameter"); @@ -2469,7 +2468,7 @@ TypeCheckCallExpr::visit (FnType &type) } } - context->insert_type (argument->get_mappings (), resolved_argument_type); + context->insert_type (argument->get_mappings (), argument_expr_tyty); i++; } @@ -2522,14 +2521,14 @@ TypeCheckCallExpr::visit (FnPtr &type) } auto resolved_argument_type = fnparam->coerce (argument_expr_tyty); - if (argument_expr_tyty->get_kind () == TyTy::TypeKind::ERROR) + if (resolved_argument_type->get_kind () == TyTy::TypeKind::ERROR) { rust_error_at (argument->get_locus (), "Type Resolution failure on parameter"); return; } - context->insert_type (argument->get_mappings (), resolved_argument_type); + context->insert_type (argument->get_mappings (), argument_expr_tyty); i++; } @@ -2575,14 +2574,14 @@ TypeCheckMethodCallExpr::visit (FnType &type) } auto resolved_argument_type = fnparam.second->coerce (argument_expr_tyty); - if (argument_expr_tyty->get_kind () == TyTy::TypeKind::ERROR) + if (resolved_argument_type->get_kind () == TyTy::TypeKind::ERROR) { rust_error_at (argument->get_locus (), "Type Resolution failure on parameter"); return; } - context->insert_type (argument->get_mappings (), resolved_argument_type); + context->insert_type (argument->get_mappings (), argument_expr_tyty); i++; } diff --git a/gcc/testsuite/rust/compile/func3.rs b/gcc/testsuite/rust/compile/func3.rs index 6cedf8e..3ab374a 100644 --- a/gcc/testsuite/rust/compile/func3.rs +++ b/gcc/testsuite/rust/compile/func3.rs @@ -3,5 +3,9 @@ fn test(a: i32, b: i32) -> i32 { } fn main() { - let a = test(1, true); // { dg-error "expected .i32. got .bool." } + let a = test(1, true); + // { dg-error "expected .i32. got .bool." "" { target *-*-* } .-1 } + // { dg-error "Type Resolution failure on parameter" "" { target *-*-* } .-2 } + // { dg-error "failed to lookup type to CallExpr" "" { target *-*-* } .-3 } + // { dg-error "failed to type resolve expression" "" { target *-*-* } .-4 } } |