mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Improve diagnostic for call to non-function. (#1245)
This commit is contained in:
@@ -1131,9 +1131,9 @@ auto TypeChecker::TypeCheckExp(Nonnull<Expression*> e,
|
||||
}
|
||||
default: {
|
||||
return CompilationError(e->source_loc())
|
||||
<< "in call, expected a function\n"
|
||||
<< *e << "\nnot an operator of type "
|
||||
<< call.function().static_type() << "\n";
|
||||
<< "in call `" << *e
|
||||
<< "`, expected callee to be a function, found `"
|
||||
<< call.function().static_type() << "`";
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -19,10 +19,7 @@ class Point {
|
||||
}
|
||||
|
||||
fn Main() -> i32 {
|
||||
// CHECK: COMPILATION ERROR: {{.*}}/explorer/testdata/generic_class/fail_instantiate_non_generic.carbon:[[@LINE+4]]: in call, expected a function
|
||||
// CHECK: Point(i32)
|
||||
// CHECK: not an operator of type typeof(class Point)
|
||||
// CHECK-EMPTY:
|
||||
// CHECK: COMPILATION ERROR: {{.*}}/explorer/testdata/generic_class/fail_instantiate_non_generic.carbon:[[@LINE+1]]: in call `Point(i32)`, expected callee to be a function, found `typeof(class Point)`
|
||||
var p: Point(i32) = Point.Origin();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -13,10 +13,7 @@ package ExplorerTest api;
|
||||
class Point(T:! Type) {
|
||||
|
||||
// Error: wrote `Self(T)` instead of `Self`.
|
||||
// CHECK: COMPILATION ERROR: {{.*}}/explorer/testdata/generic_class/fail_self_with_arg.carbon:[[@LINE+4]]: in call, expected a function
|
||||
// CHECK: Self(T)
|
||||
// CHECK: not an operator of type typeof(class Point(T = T:! Type))
|
||||
// CHECK-EMPTY:
|
||||
// CHECK: COMPILATION ERROR: {{.*}}/explorer/testdata/generic_class/fail_self_with_arg.carbon:[[@LINE+1]]: in call `Self(T)`, expected callee to be a function, found `typeof(class Point(T = T:! Type))`
|
||||
fn Origin(zero: T) -> Self(T) {
|
||||
return {.x = zero, .y = zero};
|
||||
}
|
||||
|
||||
@@ -11,10 +11,7 @@
|
||||
package ExplorerTest api;
|
||||
|
||||
class Point(T:! Type) {
|
||||
// CHECK: COMPILATION ERROR: {{.*}}/explorer/testdata/generic_class/fail_two_arg_lists.carbon:[[@LINE+4]]: in call, expected a function
|
||||
// CHECK: Point(T)(T)
|
||||
// CHECK: not an operator of type typeof(class Point(T = T:! Type))
|
||||
// CHECK-EMPTY:
|
||||
// CHECK: COMPILATION ERROR: {{.*}}/explorer/testdata/generic_class/fail_two_arg_lists.carbon:[[@LINE+1]]: in call `Point(T)(T)`, expected callee to be a function, found `typeof(class Point(T = T:! Type))`
|
||||
fn Origin(zero: T) -> Point(T)(T) {
|
||||
return {.x = zero, .y = zero};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user