Skip to content

Commit

Permalink
Move error uri at the top
Browse files Browse the repository at this point in the history
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
  • Loading branch information
VLanvin authored and facebook-github-bot committed Feb 7, 2025
1 parent 1361dc6 commit 01c58ce
Show file tree
Hide file tree
Showing 106 changed files with 1,224 additions and 3,665 deletions.
5 changes: 3 additions & 2 deletions crates/elp/src/bin/reporting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ impl<'a> Reporter for PrettyReporter<'a> {
None => "".to_string(),
};

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

term::emit(&mut self.cli, &REPORTING_CONFIG, &reporting_files, &d).unwrap();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
error: incompatible_types
error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types)
┌─ check/src/any_fun_type.erl:46:21
46 │ to_f_any_neg2(F) -> F.
│ ^ F.
Expression has type: 'f0' | fun((atom()) -> pid()) | 'f1'
Context expected type: fun()

See https://fb.me/eqwalizer_errors#incompatible_types

error: incompatible_types
error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types)
┌─ check/src/any_fun_type.erl:49:23
49 │ f_any_to_f0_neg(F) -> F.
│ ^ F.
Expression has type: fun()
Context expected type: 'f0'

See https://fb.me/eqwalizer_errors#incompatible_types

error: incompatible_types
error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types)
┌─ check/src/any_fun_type.erl:61:31
61 │ when is_function(F, 1) -> F.
Expand All @@ -27,15 +23,13 @@ error: incompatible_types
│ F.
Expression has type: fun((term()) -> term())
Context expected type: f2()

See https://fb.me/eqwalizer_errors#incompatible_types

fun((term()) -> term()) is not compatible with f2()
because
fun((term()) -> term()) is not compatible with fun((term(), term()) -> term())

error: incompatible_types
error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types)
┌─ check/src/any_fun_type.erl:92:24
92 │ f5_to_f4_cov_neg(F) -> F.
Expand All @@ -44,8 +38,6 @@ error: incompatible_types
│ F.
Expression has type: f5('a' | 'b')
Context expected type: f4('a')

See https://fb.me/eqwalizer_errors#incompatible_types

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

error: incompatible_types
error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types)
┌─ check/src/any_fun_type.erl:98:20
98 │ apply_f4_neg(F) -> F(a).
│ ^^^^ F('a').
Expression has type: number()
Context expected type: boolean()

See https://fb.me/eqwalizer_errors#incompatible_types

error: incompatible_types
error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types)
┌─ check/src/any_fun_type.erl:113:22
113 │ fun3_to_f4_neg(F) -> F.
Expand All @@ -75,8 +65,6 @@ error: incompatible_types
│ F.
Expression has type: fun((term()) -> 'a' | 'b')
Context expected type: f4('a')

See https://fb.me/eqwalizer_errors#incompatible_types

fun((term()) -> 'a' | 'b') is not compatible with f4('a')
Expand Down
36 changes: 9 additions & 27 deletions crates/elp/src/resources/test/eqwalizer_tests/check/approx.pretty
Original file line number Diff line number Diff line change
@@ -1,62 +1,50 @@
error: incompatible_types
error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types)
┌─ check/src/approx.erl:36:5
36 │ {X, X}.
│ ^^^^^^ {X, X}.
Expression has type: {dynamic(), dynamic()}
Context expected type: 'ok'

See https://fb.me/eqwalizer_errors#incompatible_types

error: unknown_id
error: unknown_id (See https://fb.me/eqwalizer_errors#unknown_id)
┌─ check/src/approx.erl:39:1
39 │ generics_with_unions:type_var_from_nowhere().
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Unknown id: generics_with_unions:type_var_from_nowhere/0

See https://fb.me/eqwalizer_errors#unknown_id

error: reference_to_invalid_type
error: reference_to_invalid_type (See https://fb.me/eqwalizer_errors#reference_to_invalid_type)
┌─ check/src/approx.erl:41:1
41 │ ╭ -spec test_trans_invalid1_neg(
42 │ │ trans_invalid()
43 │ │ ) -> nok.
│ ╰────────^ test_trans_invalid1_neg/1 references type with invalid definition: trans_invalid/0

See https://fb.me/eqwalizer_errors#reference_to_invalid_type

error: reference_to_invalid_type
error: reference_to_invalid_type (See https://fb.me/eqwalizer_errors#reference_to_invalid_type)
┌─ check/src/approx.erl:47:1
47 │ ╭ -spec test_trans_invalid2_neg(
48 │ │ trans_invalid()
49 │ │ ) -> nok.
│ ╰────────^ test_trans_invalid2_neg/1 references type with invalid definition: trans_invalid/0

See https://fb.me/eqwalizer_errors#reference_to_invalid_type

error: reference_to_invalid_type
error: reference_to_invalid_type (See https://fb.me/eqwalizer_errors#reference_to_invalid_type)
┌─ check/src/approx.erl:53:1
53 │ ╭ -spec test_trans_invalid3_neg(
54 │ │ trans_invalid()
55 │ │ ) -> nok.
│ ╰────────^ test_trans_invalid3_neg/1 references type with invalid definition: trans_invalid/0

See https://fb.me/eqwalizer_errors#reference_to_invalid_type

error: expected_fun_type
error: expected_fun_type (See https://fb.me/eqwalizer_errors#expected_fun_type)
┌─ check/src/approx.erl:62:30
62 │ test_opaque_as_fun_neg(X) -> X(ok).
│ ^ X.
Expected fun type with arity 1
Got: misc:o() | fun((term()) -> none())

See https://fb.me/eqwalizer_errors#expected_fun_type

error: incompatible_types
error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types)
┌─ check/src/approx.erl:69:3
69 │ Dyn2.
Expand All @@ -65,28 +53,22 @@ error: incompatible_types
│ Dyn2.
Expression has type: string() | dynamic()
Context expected type: 'anything'

See https://fb.me/eqwalizer_errors#incompatible_types

string() | dynamic() is not compatible with 'anything'
because
string() is not compatible with 'anything'

error: reveal_type
error: reveal_type (See https://fb.me/eqwalizer_errors#reveal_type)
┌─ check/src/approx.erl:79:25
79 │ eqwalizer:reveal_type(Res),
│ ^^^ dynamic(number())

See https://fb.me/eqwalizer_errors#reveal_type

error: reveal_type
error: reveal_type (See https://fb.me/eqwalizer_errors#reveal_type)
┌─ check/src/approx.erl:90:25
90 │ eqwalizer:reveal_type(Res),
│ ^^^ dynamic(number())

See https://fb.me/eqwalizer_errors#reveal_type

9 ERRORS
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
error: incompatible_types
error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types)
┌─ check/src/as_pat.erl:51:38
51 │ unboxL_neg(BN = #box_n{}) -> unbox_a(BN).
│ ^^ BN.
Expression has type: #box_n{}
Context expected type: #box_a{}

See https://fb.me/eqwalizer_errors#incompatible_types

error: incompatible_types
error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types)
┌─ check/src/as_pat.erl:61:38
61 │ unboxR_neg(#box_n{} = BN) -> unbox_b(BN).
│ ^^ BN.
Expression has type: #box_n{}
Context expected type: #box_b{}

See https://fb.me/eqwalizer_errors#incompatible_types

2 ERRORS
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error: incompatible_types
error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types)
┌─ check/src/auto_imports.erl:22:20
22 │ erlang:error(ok, ok).
Expand All @@ -7,8 +7,6 @@ error: incompatible_types
│ 'ok'.
Expression has type: 'ok'
Context expected type: [term()] | 'none'

See https://fb.me/eqwalizer_errors#incompatible_types

'ok' is not compatible with [term()] | 'none'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
error: unknown_id
error: unknown_id (See https://fb.me/eqwalizer_errors#unknown_id)
┌─ check/src/behave.erl:8:20
8 │ -callback foo() -> behave1:test().
│ ^^^^^^^^^^^^^^ Unknown id: behave1:test/0

See https://fb.me/eqwalizer_errors#unknown_id

error: unbound_type_var
error: unbound_type_var (See https://fb.me/eqwalizer_errors#unbound_type_var)
┌─ check/src/behave.erl:10:1
10 │ -type invalid() :: _T.
│ ^^^^^^^^^^^^^^^^^^^^^ _T: Type variable is unbound.

See https://fb.me/eqwalizer_errors#unbound_type_var

2 ERRORS
Original file line number Diff line number Diff line change
@@ -1,81 +1,65 @@
error: incompatible_types
error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types)
┌─ check/src/binaries.erl:24:17
24 │ test04_neg() -> <<>>.
│ ^^^^ <<..>>.
Expression has type: binary()
Context expected type: [term()]

See https://fb.me/eqwalizer_errors#incompatible_types

error: incompatible_types
error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types)
┌─ check/src/binaries.erl:32:20
32 │ test05_neg(A) -> <<A/signed>>.
│ ^ A.
Expression has type: atom()
Context expected type: number()

See https://fb.me/eqwalizer_errors#incompatible_types

error: incompatible_types
error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types)
┌─ check/src/binaries.erl:35:23
35 │ test06_neg(A, S) -> <<A:S>>.
│ ^ A.
Expression has type: atom()
Context expected type: number()

See https://fb.me/eqwalizer_errors#incompatible_types

error: incompatible_types
error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types)
┌─ check/src/binaries.erl:38:18
38 │ test07_neg(A) -> [A].
│ ^^^ [A].
Expression has type: [atom()]
Context expected type: binary()

See https://fb.me/eqwalizer_errors#incompatible_types

error: incompatible_types
error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types)
┌─ check/src/binaries.erl:55:7
55 │ <<"binary"/binary>>.
│ ^^^^^^^^ string_lit.
Expression has type: string()
Context expected type: binary()

See https://fb.me/eqwalizer_errors#incompatible_types

error: incompatible_types
error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types)
┌─ check/src/binaries.erl:74:9
74 │ <<X:A>> = Bits,
│ ^ A.
Expression has type: atom()
Context expected type: number()

See https://fb.me/eqwalizer_errors#incompatible_types

error: incompatible_types
error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types)
┌─ check/src/binaries.erl:80:9
80 │ <<X:(self())>> = Bits,
│ ^^^^^^^^ erlang:self().
Expression has type: pid()
Context expected type: number()

See https://fb.me/eqwalizer_errors#incompatible_types

error: incompatible_types
error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types)
┌─ check/src/binaries.erl:89:7
89 │ <<[]>>.
│ ^^ [].
Expression has type: []
Context expected type: number()

See https://fb.me/eqwalizer_errors#incompatible_types

8 ERRORS
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
error: incompatible_types
error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types)
┌─ check/src/booleans.erl:47:3
47 │ 1 andalso b().
│ ^ 1.
Expression has type: number()
Context expected type: boolean()

See https://fb.me/eqwalizer_errors#incompatible_types

error: incompatible_types
error: incompatible_types (See https://fb.me/eqwalizer_errors#incompatible_types)
┌─ check/src/booleans.erl:59:3
59 │ dyn() andalso only_true().
Expand All @@ -17,8 +15,6 @@ error: incompatible_types
│ _ andalso _.
Expression has type: 'false' | 'true'
Context expected type: 'true'

See https://fb.me/eqwalizer_errors#incompatible_types

'false' | 'true' is not compatible with 'true'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
error: incorrect_return_type_in_cb_implementation
error: incorrect_return_type_in_cb_implementation (See https://fb.me/eqwalizer_errors#incorrect_return_type_in_cb_implementation)
┌─ check/src/callbacks3_neg.erl:12:1
12 │ -behavior(gen_server).
│ ^^^^^^^^^^^^^^^^^^^^^
│ │
│ 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'.

See https://fb.me/eqwalizer_errors#incorrect_return_type_in_cb_implementation

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

0 comments on commit 01c58ce

Please sign in to comment.