Switch from llvm::errs()+exit() to FATAL_USER_ERROR() stream-based handling. (#670)

This is intended to:

- Standardize use of line_num (and highlight where no line_num is available).
- Standardize indications of runtime/compilation errors.
- Make it incrementally easier to write new errors.

Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
This commit is contained in:
Jon Meow
2021-07-28 10:47:33 -07:00
committed by GitHub
co-authored by Chandler Carruth
parent dcc694c2e0
commit f0af3cb795
24 changed files with 206 additions and 170 deletions
@@ -1,2 +1,2 @@
12: undefined behavior: access to dead value 1
RUNTIME ERROR: 12: : undefined behavior: access to dead value 1
EXIT CODE: 255
+1 -1
View File
@@ -1,2 +1,2 @@
10: compilation error, tuples of different length
COMPILATION ERROR: 10: tuples of different length
EXIT CODE: 255
@@ -1,4 +1,4 @@
ERROR: 10: type error in argument deduction
COMPILATION ERROR: 10: type error in argument deduction
expected: Int
actual: Bool
EXIT CODE: 255
@@ -1,4 +1,4 @@
ERROR: 6: type error in addition(1)
COMPILATION ERROR: 6: type error in addition(1)
expected: Int
actual: T
EXIT CODE: 255
+1 -1
View File
@@ -1,4 +1,4 @@
ERROR: 7: type error in initializer of variable
COMPILATION ERROR: 7: type error in initializer of variable
expected: Int
actual: Bool
EXIT CODE: 255
+1 -1
View File
@@ -1,4 +1,4 @@
ERROR: 10: type error in return
COMPILATION ERROR: 10: type error in return
expected: ()
actual: Int
EXIT CODE: 255
+1 -1
View File
@@ -1,2 +1,2 @@
8: could not find `y`
RUNTIME ERROR: 8: : could not find `y`
EXIT CODE: 255
+1 -1
View File
@@ -1,2 +1,2 @@
7: compilation error, pattern variables are only allowed in pattern context
COMPILATION ERROR: 7: pattern variables are only allowed in pattern context
EXIT CODE: 255
@@ -0,0 +1,12 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
struct Point {
var x: Int;
var y: Int;
}
fn main() -> Int {
return Point(.x = 1, .y = 2).z - 1;
}
@@ -0,0 +1,2 @@
COMPILATION ERROR: 11: struct Point does not have a field named z
EXIT CODE: 255
@@ -0,0 +1,12 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
struct Point {
var x: Int;
var y: Int;
}
fn main() -> Int {
return Point(.x = 1, .z = 2).x - 1;
}
@@ -0,0 +1,2 @@
COMPILATION ERROR: 11: field names do not match, expected y but got z
EXIT CODE: 255
@@ -0,0 +1,12 @@
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
struct Point {
var x: Int;
var y: Int;
}
fn main() -> Int {
return Point(.x = 1).x - 1;
}
@@ -0,0 +1,2 @@
COMPILATION ERROR: 11: tuples of different length
EXIT CODE: 255
+1 -1
View File
@@ -1,4 +1,4 @@
ERROR: 8: type error in pattern variable
COMPILATION ERROR: 8: type error in pattern variable
expected: (x = Int, y = Int)
actual: (y = Int, x = Int)
EXIT CODE: 255
+1 -1
View File
@@ -1,4 +1,4 @@
ERROR: 8: type error in ==
COMPILATION ERROR: 8: type error in ==
expected: (0 = Int, 1 = Int)
actual: (0 = Int)
EXIT CODE: 255