Skip to content

Commit 01c58ce

Browse files
VLanvinfacebook-github-bot
authored andcommitted
Move error uri at the top
Summary: Error URIs tend to break error messages in half, making them harder to read. Move URIs to the top to avoid that. The only change is in `reporting.rs` Reviewed By: ilya-klyuchnikov Differential Revision: D69245456 fbshipit-source-id: f29a7c28f08d1a81e1a4efa14aa8bd4c3a60c061
1 parent 1361dc6 commit 01c58ce

File tree

106 files changed

+1224
-3665
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+1224
-3665
lines changed

crates/elp/src/bin/reporting.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@ impl<'a> Reporter for PrettyReporter<'a> {
120120
None => "".to_string(),
121121
};
122122

123-
let msg = format!("{}{}\n\nSee {}", expr, diagnostic.message, diagnostic.uri);
123+
let code = format!("{} (See {})", diagnostic.code, diagnostic.uri);
124+
let msg = format!("{}{}", expr, diagnostic.message);
124125
let msg_label = Label::primary(reporting_id, range.clone()).with_message(&msg);
125126
let mut labels = vec![msg_label];
126127
if let Some(s) = &diagnostic.explanation {
@@ -129,7 +130,7 @@ impl<'a> Reporter for PrettyReporter<'a> {
129130
labels.push(explanation_label);
130131
};
131132
let d: ReportingDiagnostic<usize> = ReportingDiagnostic::error()
132-
.with_message(&diagnostic.code)
133+
.with_message(code)
133134
.with_labels(labels);
134135

135136
term::emit(&mut self.cli, &REPORTING_CONFIG, &reporting_files, &d).unwrap();

crates/elp/src/resources/test/eqwalizer_tests/check/any_fun_type.pretty

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,20 @@
1-
error: incompatible_types
1+
error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types)
22
┌─ check/src/any_fun_type.erl:46:21
33
44
46 │ to_f_any_neg2(F) -> F.
55
│ ^ F.
66
Expression has type: 'f0' | fun((atom()) -> pid()) | 'f1'
77
Context expected type: fun()
88

9-
See https://fb.me/eqwalizer_errors#incompatible_types
10-
11-
error: incompatible_types
9+
error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types)
1210
┌─ check/src/any_fun_type.erl:49:23
1311
1412
49 │ f_any_to_f0_neg(F) -> F.
1513
│ ^ F.
1614
Expression has type: fun()
1715
Context expected type: 'f0'
1816

19-
See https://fb.me/eqwalizer_errors#incompatible_types
20-
21-
error: incompatible_types
17+
error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types)
2218
┌─ check/src/any_fun_type.erl:61:31
2319
2420
61 │ when is_function(F, 1) -> F.
@@ -27,15 +23,13 @@ error: incompatible_types
2723
│ F.
2824
Expression has type: fun((term()) -> term())
2925
Context expected type: f2()
30-
31-
See https://fb.me/eqwalizer_errors#incompatible_types
3226
3327

3428
fun((term()) -> term()) is not compatible with f2()
3529
because
3630
fun((term()) -> term()) is not compatible with fun((term(), term()) -> term())
3731

38-
error: incompatible_types
32+
error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types)
3933
┌─ check/src/any_fun_type.erl:92:24
4034
4135
92 │ f5_to_f4_cov_neg(F) -> F.
@@ -44,8 +38,6 @@ error: incompatible_types
4438
│ F.
4539
Expression has type: f5('a' | 'b')
4640
Context expected type: f4('a')
47-
48-
See https://fb.me/eqwalizer_errors#incompatible_types
4941
5042

5143
f5('a' | 'b') is not compatible with f4('a')
@@ -56,17 +48,15 @@ See https://fb.me/eqwalizer_errors#incompatible_types
5648
because
5749
'a' | 'b' is not compatible with 'a'
5850

59-
error: incompatible_types
51+
error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types)
6052
┌─ check/src/any_fun_type.erl:98:20
6153
6254
98 │ apply_f4_neg(F) -> F(a).
6355
│ ^^^^ F('a').
6456
Expression has type: number()
6557
Context expected type: boolean()
6658

67-
See https://fb.me/eqwalizer_errors#incompatible_types
68-
69-
error: incompatible_types
59+
error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types)
7060
┌─ check/src/any_fun_type.erl:113:22
7161
7262
113 │ fun3_to_f4_neg(F) -> F.
@@ -75,8 +65,6 @@ error: incompatible_types
7565
│ F.
7666
Expression has type: fun((term()) -> 'a' | 'b')
7767
Context expected type: f4('a')
78-
79-
See https://fb.me/eqwalizer_errors#incompatible_types
8068
8169

8270
fun((term()) -> 'a' | 'b') is not compatible with f4('a')
Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,50 @@
1-
error: incompatible_types
1+
error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types)
22
┌─ check/src/approx.erl:36:5
33
44
36 │ {X, X}.
55
│ ^^^^^^ {X, X}.
66
Expression has type: {dynamic(), dynamic()}
77
Context expected type: 'ok'
88

9-
See https://fb.me/eqwalizer_errors#incompatible_types
10-
11-
error: unknown_id
9+
error: unknown_id (See https://fb.me/eqwalizer_errors#unknown_id)
1210
┌─ check/src/approx.erl:39:1
1311
1412
39 │ generics_with_unions:type_var_from_nowhere().
1513
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Unknown id: generics_with_unions:type_var_from_nowhere/0
1614

17-
See https://fb.me/eqwalizer_errors#unknown_id
18-
19-
error: reference_to_invalid_type
15+
error: reference_to_invalid_type (See https://fb.me/eqwalizer_errors#reference_to_invalid_type)
2016
┌─ check/src/approx.erl:41:1
2117
2218
41 │ ╭ -spec test_trans_invalid1_neg(
2319
42 │ │ trans_invalid()
2420
43 │ │ ) -> nok.
2521
│ ╰────────^ test_trans_invalid1_neg/1 references type with invalid definition: trans_invalid/0
2622

27-
See https://fb.me/eqwalizer_errors#reference_to_invalid_type
28-
29-
error: reference_to_invalid_type
23+
error: reference_to_invalid_type (See https://fb.me/eqwalizer_errors#reference_to_invalid_type)
3024
┌─ check/src/approx.erl:47:1
3125
3226
47 │ ╭ -spec test_trans_invalid2_neg(
3327
48 │ │ trans_invalid()
3428
49 │ │ ) -> nok.
3529
│ ╰────────^ test_trans_invalid2_neg/1 references type with invalid definition: trans_invalid/0
3630

37-
See https://fb.me/eqwalizer_errors#reference_to_invalid_type
38-
39-
error: reference_to_invalid_type
31+
error: reference_to_invalid_type (See https://fb.me/eqwalizer_errors#reference_to_invalid_type)
4032
┌─ check/src/approx.erl:53:1
4133
4234
53 │ ╭ -spec test_trans_invalid3_neg(
4335
54 │ │ trans_invalid()
4436
55 │ │ ) -> nok.
4537
│ ╰────────^ test_trans_invalid3_neg/1 references type with invalid definition: trans_invalid/0
4638

47-
See https://fb.me/eqwalizer_errors#reference_to_invalid_type
48-
49-
error: expected_fun_type
39+
error: expected_fun_type (See https://fb.me/eqwalizer_errors#expected_fun_type)
5040
┌─ check/src/approx.erl:62:30
5141
5242
62 │ test_opaque_as_fun_neg(X) -> X(ok).
5343
│ ^ X.
5444
Expected fun type with arity 1
5545
Got: misc:o() | fun((term()) -> none())
5646

57-
See https://fb.me/eqwalizer_errors#expected_fun_type
58-
59-
error: incompatible_types
47+
error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types)
6048
┌─ check/src/approx.erl:69:3
6149
6250
69 │ Dyn2.
@@ -65,28 +53,22 @@ error: incompatible_types
6553
│ Dyn2.
6654
Expression has type: string() | dynamic()
6755
Context expected type: 'anything'
68-
69-
See https://fb.me/eqwalizer_errors#incompatible_types
7056
7157

7258
string() | dynamic() is not compatible with 'anything'
7359
because
7460
string() is not compatible with 'anything'
7561

76-
error: reveal_type
62+
error: reveal_type (See https://fb.me/eqwalizer_errors#reveal_type)
7763
┌─ check/src/approx.erl:79:25
7864
7965
79 │ eqwalizer:reveal_type(Res),
8066
│ ^^^ dynamic(number())
8167

82-
See https://fb.me/eqwalizer_errors#reveal_type
83-
84-
error: reveal_type
68+
error: reveal_type (See https://fb.me/eqwalizer_errors#reveal_type)
8569
┌─ check/src/approx.erl:90:25
8670
8771
90 │ eqwalizer:reveal_type(Res),
8872
│ ^^^ dynamic(number())
8973

90-
See https://fb.me/eqwalizer_errors#reveal_type
91-
9274
9 ERRORS
Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
1-
error: incompatible_types
1+
error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types)
22
┌─ check/src/as_pat.erl:51:38
33
44
51 │ unboxL_neg(BN = #box_n{}) -> unbox_a(BN).
55
│ ^^ BN.
66
Expression has type: #box_n{}
77
Context expected type: #box_a{}
88

9-
See https://fb.me/eqwalizer_errors#incompatible_types
10-
11-
error: incompatible_types
9+
error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types)
1210
┌─ check/src/as_pat.erl:61:38
1311
1412
61 │ unboxR_neg(#box_n{} = BN) -> unbox_b(BN).
1513
│ ^^ BN.
1614
Expression has type: #box_n{}
1715
Context expected type: #box_b{}
1816

19-
See https://fb.me/eqwalizer_errors#incompatible_types
20-
2117
2 ERRORS

crates/elp/src/resources/test/eqwalizer_tests/check/auto_imports.pretty

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: incompatible_types
1+
error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types)
22
┌─ check/src/auto_imports.erl:22:20
33
44
22 │ erlang:error(ok, ok).
@@ -7,8 +7,6 @@ error: incompatible_types
77
│ 'ok'.
88
Expression has type: 'ok'
99
Context expected type: [term()] | 'none'
10-
11-
See https://fb.me/eqwalizer_errors#incompatible_types
1210
1311

1412
'ok' is not compatible with [term()] | 'none'
Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
1-
error: unknown_id
1+
error: unknown_id (See https://fb.me/eqwalizer_errors#unknown_id)
22
┌─ check/src/behave.erl:8:20
33
44
8 │ -callback foo() -> behave1:test().
55
│ ^^^^^^^^^^^^^^ Unknown id: behave1:test/0
66

7-
See https://fb.me/eqwalizer_errors#unknown_id
8-
9-
error: unbound_type_var
7+
error: unbound_type_var (See https://fb.me/eqwalizer_errors#unbound_type_var)
108
┌─ check/src/behave.erl:10:1
119
1210
10 │ -type invalid() :: _T.
1311
│ ^^^^^^^^^^^^^^^^^^^^^ _T: Type variable is unbound.
1412

15-
See https://fb.me/eqwalizer_errors#unbound_type_var
16-
1713
2 ERRORS
Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,65 @@
1-
error: incompatible_types
1+
error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types)
22
┌─ check/src/binaries.erl:24:17
33
44
24 │ test04_neg() -> <<>>.
55
│ ^^^^ <<..>>.
66
Expression has type: binary()
77
Context expected type: [term()]
88

9-
See https://fb.me/eqwalizer_errors#incompatible_types
10-
11-
error: incompatible_types
9+
error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types)
1210
┌─ check/src/binaries.erl:32:20
1311
1412
32 │ test05_neg(A) -> <<A/signed>>.
1513
│ ^ A.
1614
Expression has type: atom()
1715
Context expected type: number()
1816

19-
See https://fb.me/eqwalizer_errors#incompatible_types
20-
21-
error: incompatible_types
17+
error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types)
2218
┌─ check/src/binaries.erl:35:23
2319
2420
35 │ test06_neg(A, S) -> <<A:S>>.
2521
│ ^ A.
2622
Expression has type: atom()
2723
Context expected type: number()
2824

29-
See https://fb.me/eqwalizer_errors#incompatible_types
30-
31-
error: incompatible_types
25+
error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types)
3226
┌─ check/src/binaries.erl:38:18
3327
3428
38 │ test07_neg(A) -> [A].
3529
│ ^^^ [A].
3630
Expression has type: [atom()]
3731
Context expected type: binary()
3832

39-
See https://fb.me/eqwalizer_errors#incompatible_types
40-
41-
error: incompatible_types
33+
error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types)
4234
┌─ check/src/binaries.erl:55:7
4335
4436
55 │ <<"binary"/binary>>.
4537
│ ^^^^^^^^ string_lit.
4638
Expression has type: string()
4739
Context expected type: binary()
4840

49-
See https://fb.me/eqwalizer_errors#incompatible_types
50-
51-
error: incompatible_types
41+
error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types)
5242
┌─ check/src/binaries.erl:74:9
5343
5444
74 │ <<X:A>> = Bits,
5545
│ ^ A.
5646
Expression has type: atom()
5747
Context expected type: number()
5848

59-
See https://fb.me/eqwalizer_errors#incompatible_types
60-
61-
error: incompatible_types
49+
error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types)
6250
┌─ check/src/binaries.erl:80:9
6351
6452
80 │ <<X:(self())>> = Bits,
6553
│ ^^^^^^^^ erlang:self().
6654
Expression has type: pid()
6755
Context expected type: number()
6856

69-
See https://fb.me/eqwalizer_errors#incompatible_types
70-
71-
error: incompatible_types
57+
error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types)
7258
┌─ check/src/binaries.erl:89:7
7359
7460
89 │ <<[]>>.
7561
│ ^^ [].
7662
Expression has type: []
7763
Context expected type: number()
7864

79-
See https://fb.me/eqwalizer_errors#incompatible_types
80-
8165
8 ERRORS

crates/elp/src/resources/test/eqwalizer_tests/check/booleans.pretty

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
error: incompatible_types
1+
error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types)
22
┌─ check/src/booleans.erl:47:3
33
44
47 │ 1 andalso b().
55
│ ^ 1.
66
Expression has type: number()
77
Context expected type: boolean()
88

9-
See https://fb.me/eqwalizer_errors#incompatible_types
10-
11-
error: incompatible_types
9+
error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types)
1210
┌─ check/src/booleans.erl:59:3
1311
1412
59 │ dyn() andalso only_true().
@@ -17,8 +15,6 @@ error: incompatible_types
1715
│ _ andalso _.
1816
Expression has type: 'false' | 'true'
1917
Context expected type: 'true'
20-
21-
See https://fb.me/eqwalizer_errors#incompatible_types
2218
2319

2420
'false' | 'true' is not compatible with 'true'

crates/elp/src/resources/test/eqwalizer_tests/check/callbacks3_neg.pretty

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
error: incorrect_return_type_in_cb_implementation
1+
error: incorrect_return_type_in_cb_implementation (See https://fb.me/eqwalizer_errors#incorrect_return_type_in_cb_implementation)
22
┌─ check/src/callbacks3_neg.erl:12:1
33
44
12 │ -behavior(gen_server).
55
│ ^^^^^^^^^^^^^^^^^^^^^
66
│ │
77
│ Incorrect return type for implementation of gen_server:handle_cast/2. Expected: {'noreply', term()} | {'noreply', term(), timeout() | 'hibernate' | {'continue', term()}} | {'stop', term(), term()}, Got: 'wrong_ret'.
8-
9-
See https://fb.me/eqwalizer_errors#incorrect_return_type_in_cb_implementation
108
119

1210
'wrong_ret' is not compatible with {'noreply', term()} | {'noreply', term(), timeout() | 'hibernate' | {'continue', term()}} | {'stop', term(), term()}

0 commit comments

Comments
 (0)