mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-04 22:02:52 +01:00
Add line output to diagnostics to help identify error locations. (#3010)
This also makes the filename a reference to the buffer since the line seems better to have as a reference (versus copying a string per error). Most tests now have different line deltas due to the extra output, but the actual errors should overall stay the same. Some of the error locations look like they could be improved, but this change is only making it clear where they were before.
This commit is contained in:
@@ -133,24 +133,48 @@ fn Run1(a: i32) {}
|
||||
fn Run2(a: i32, b: i32) {}
|
||||
|
||||
fn Main() {
|
||||
// CHECK:STDERR: fail_param_count.carbon:[[@LINE+2]]:7: No matching callable was found.
|
||||
// CHECK:STDERR: fail_param_count.carbon:[[@LINE-6]]:1: Function cannot be used: Received 1 argument(s), but require 0 argument(s).
|
||||
// CHECK:STDERR: fail_param_count.carbon:[[@LINE+6]]:7: No matching callable was found.
|
||||
// CHECK:STDERR: Run0(1);
|
||||
// CHECK:STDERR: ^
|
||||
// CHECK:STDERR: fail_param_count.carbon:[[@LINE-8]]:1: Function cannot be used: Received 1 argument(s), but require 0 argument(s).
|
||||
// CHECK:STDERR: fn Run0() {}
|
||||
// CHECK:STDERR: ^
|
||||
Run0(1);
|
||||
// CHECK:STDERR: fail_param_count.carbon:[[@LINE+2]]:7: No matching callable was found.
|
||||
// CHECK:STDERR: fail_param_count.carbon:[[@LINE-9]]:1: Function cannot be used: Received 2 argument(s), but require 0 argument(s).
|
||||
// CHECK:STDERR: fail_param_count.carbon:[[@LINE+6]]:7: No matching callable was found.
|
||||
// CHECK:STDERR: Run0(0, 1);
|
||||
// CHECK:STDERR: ^
|
||||
// CHECK:STDERR: fail_param_count.carbon:[[@LINE-15]]:1: Function cannot be used: Received 2 argument(s), but require 0 argument(s).
|
||||
// CHECK:STDERR: fn Run0() {}
|
||||
// CHECK:STDERR: ^
|
||||
Run0(0, 1);
|
||||
|
||||
// CHECK:STDERR: fail_param_count.carbon:[[@LINE+2]]:7: No matching callable was found.
|
||||
// CHECK:STDERR: fail_param_count.carbon:[[@LINE-12]]:1: Function cannot be used: Received 0 argument(s), but require 1 argument(s).
|
||||
// CHECK:STDERR: fail_param_count.carbon:[[@LINE+6]]:7: No matching callable was found.
|
||||
// CHECK:STDERR: Run1();
|
||||
// CHECK:STDERR: ^
|
||||
// CHECK:STDERR: fail_param_count.carbon:[[@LINE-22]]:1: Function cannot be used: Received 0 argument(s), but require 1 argument(s).
|
||||
// CHECK:STDERR: fn Run1(a: i32) {}
|
||||
// CHECK:STDERR: ^
|
||||
Run1();
|
||||
// CHECK:STDERR: fail_param_count.carbon:[[@LINE+2]]:7: No matching callable was found.
|
||||
// CHECK:STDERR: fail_param_count.carbon:[[@LINE-15]]:1: Function cannot be used: Received 2 argument(s), but require 1 argument(s).
|
||||
// CHECK:STDERR: fail_param_count.carbon:[[@LINE+6]]:7: No matching callable was found.
|
||||
// CHECK:STDERR: Run1(0, 1);
|
||||
// CHECK:STDERR: ^
|
||||
// CHECK:STDERR: fail_param_count.carbon:[[@LINE-29]]:1: Function cannot be used: Received 2 argument(s), but require 1 argument(s).
|
||||
// CHECK:STDERR: fn Run1(a: i32) {}
|
||||
// CHECK:STDERR: ^
|
||||
Run1(0, 1);
|
||||
|
||||
// CHECK:STDERR: fail_param_count.carbon:[[@LINE+2]]:7: No matching callable was found.
|
||||
// CHECK:STDERR: fail_param_count.carbon:[[@LINE-18]]:1: Function cannot be used: Received 0 argument(s), but require 2 argument(s).
|
||||
// CHECK:STDERR: fail_param_count.carbon:[[@LINE+6]]:7: No matching callable was found.
|
||||
// CHECK:STDERR: Run2();
|
||||
// CHECK:STDERR: ^
|
||||
// CHECK:STDERR: fail_param_count.carbon:[[@LINE-36]]:1: Function cannot be used: Received 0 argument(s), but require 2 argument(s).
|
||||
// CHECK:STDERR: fn Run2(a: i32, b: i32) {}
|
||||
// CHECK:STDERR: ^
|
||||
Run2();
|
||||
// CHECK:STDERR: fail_param_count.carbon:[[@LINE+2]]:7: No matching callable was found.
|
||||
// CHECK:STDERR: fail_param_count.carbon:[[@LINE-21]]:1: Function cannot be used: Received 1 argument(s), but require 2 argument(s).
|
||||
// CHECK:STDERR: fail_param_count.carbon:[[@LINE+6]]:7: No matching callable was found.
|
||||
// CHECK:STDERR: Run2(0);
|
||||
// CHECK:STDERR: ^
|
||||
// CHECK:STDERR: fail_param_count.carbon:[[@LINE-43]]:1: Function cannot be used: Received 1 argument(s), but require 2 argument(s).
|
||||
// CHECK:STDERR: fn Run2(a: i32, b: i32) {}
|
||||
// CHECK:STDERR: ^
|
||||
Run2(0);
|
||||
}
|
||||
|
||||
@@ -65,7 +65,11 @@
|
||||
fn Run(a: i32) {}
|
||||
|
||||
fn Main() {
|
||||
// CHECK:STDERR: fail_param_type.carbon:[[@LINE+2]]:6: No matching callable was found.
|
||||
// CHECK:STDERR: fail_param_type.carbon:[[@LINE-4]]:1: Function cannot be used: Cannot implicityly convert argument 0 from `f64` to `i32`.
|
||||
// CHECK:STDERR: fail_param_type.carbon:[[@LINE+6]]:6: No matching callable was found.
|
||||
// CHECK:STDERR: Run(1.0);
|
||||
// CHECK:STDERR: ^
|
||||
// CHECK:STDERR: fail_param_type.carbon:[[@LINE-6]]:1: Function cannot be used: Cannot implicityly convert argument 0 from `f64` to `i32`.
|
||||
// CHECK:STDERR: fn Run(a: i32) {}
|
||||
// CHECK:STDERR: ^
|
||||
Run(1.0);
|
||||
}
|
||||
|
||||
+3
-1
@@ -59,6 +59,8 @@
|
||||
fn Foo() -> f64 { return 1.0; }
|
||||
|
||||
fn Run() {
|
||||
// CHECK:STDERR: fail_return_type_mismatch.carbon:[[@LINE+1]]:21: Cannot implicitly convert from `f64` to `i32`.
|
||||
// CHECK:STDERR: fail_return_type_mismatch.carbon:[[@LINE+3]]:21: Cannot implicitly convert from `f64` to `i32`.
|
||||
// CHECK:STDERR: var x: i32 = Foo();
|
||||
// CHECK:STDERR: ^
|
||||
var x: i32 = Foo();
|
||||
}
|
||||
|
||||
+6
-2
@@ -50,6 +50,10 @@
|
||||
// CHECK:STDOUT: ],
|
||||
// CHECK:STDOUT: ]
|
||||
|
||||
// CHECK:STDERR: fail_param_name_conflict.carbon:[[@LINE+2]]:16: Duplicate name being declared in the same scope.
|
||||
// CHECK:STDERR: fail_param_name_conflict.carbon:[[@LINE+1]]:8: Name is previously declared here.
|
||||
// CHECK:STDERR: fail_param_name_conflict.carbon:[[@LINE+6]]:16: Duplicate name being declared in the same scope.
|
||||
// CHECK:STDERR: fn Bar(a: i32, a: i32) {}
|
||||
// CHECK:STDERR: ^
|
||||
// CHECK:STDERR: fail_param_name_conflict.carbon:[[@LINE+3]]:8: Name is previously declared here.
|
||||
// CHECK:STDERR: fn Bar(a: i32, a: i32) {}
|
||||
// CHECK:STDERR: ^
|
||||
fn Bar(a: i32, a: i32) {}
|
||||
|
||||
Reference in New Issue
Block a user