Skip to content

Commit 01a596f

Browse files
committedMar 19, 2021
[Super errors] Add the last line of a file to the code frame
This is technically a small bug from way back. The recent refactor rescript-lang#5013 allowed us to fix this.
1 parent 39db854 commit 01a596f

26 files changed

+24
-30
lines changed
 

‎jscomp/build_tests/super_errors/expected/collections.re.expected

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
1 │ /* wrong type in a list */
66
2 │ [1, 2, "Hello"] -> ignore;
7+
3 │
78

89
This has type: string
910
Somewhere wanted: int

‎jscomp/build_tests/super_errors/expected/highlighting2.re.expected

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
2 ┆ let a: int = "hel
77
3 ┆
88
4 ┆ lo";
9+
5 ┆
910

1011
This has type: string
1112
Somewhere wanted: int

‎jscomp/build_tests/super_errors/expected/highlighting3.re.expected

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
2 │ let a: int = "helllllll
77
3 │
88
4 │ loooooooooooooo";
9+
5 │
910

1011
This has type: string
1112
Somewhere wanted: int

‎jscomp/build_tests/super_errors/expected/highlighting5.re.expected

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
1 │ /* overflows in the terminal */
66
2 │ let a: int = "hellllllllllllllllllllllllllllllllllllllllllllllllllllllll
77
lllllllllllllllllllllllllll";
8+
3 │
89

910
This has type: string
1011
Somewhere wanted: int

‎jscomp/build_tests/super_errors/expected/highlighting6.re.expected

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
1 │ let aaaaa = 10;
66
2 │ let b = aaaab;
7+
3 │
78

89
The value aaaab can't be found
910

‎jscomp/build_tests/super_errors/expected/modules1.re.expected

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
/.../fixtures/modules1.re:1:9-13
44

55
1 │ let b = Foo.b;
6+
2 │
67

78
The module or file Foo can't be found.
89
- If it's a third-party dependency:

‎jscomp/build_tests/super_errors/expected/modules3.re.expected

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
10 │
77
11 │ let asd = A.B.C.D.aaa;
88
12 │
9+
13 │
910

1011
The value aaa can't be found in A.B.C.D
1112

‎jscomp/build_tests/super_errors/expected/moreArguments1.re.expected

+1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44

55
1 │ let x = (~a, ~b) => a + b;
66
2 │ let y = x(~a=2) + 2;
7+
3 │
78

89
This call is missing an argument of type (~b: int)

‎jscomp/build_tests/super_errors/expected/moreArguments2.re.expected

+1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44

55
1 │ let x = (a, b) => a + b;
66
2 │ let y = x(2) + 2;
7+
3 │
78

89
This call is missing an argument of type int

‎jscomp/build_tests/super_errors/expected/moreArguments3.re.expected

+1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44

55
1 │ let x = (a, b, c, d) => a + b;
66
2 │ let y = x(2) + 2;
7+
3 │
78

89
This call is missing arguments of type: int, 'a, 'b

‎jscomp/build_tests/super_errors/expected/moreArguments4.re.expected

+1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44

55
1 │ let x = (a, ~b, ~c, ~d) => a + b;
66
2 │ let y = x(2) + 2;
7+
3 │
78

89
This call is missing arguments of type: (~b: int), (~c: 'a), (~d: 'b)

‎jscomp/build_tests/super_errors/expected/primitives1.re.expected

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
1 │ /* got float, wanted int */
66
2 │ 2. + 2;
7+
3 │
78

89
This has type: float
910
Somewhere wanted: int

‎jscomp/build_tests/super_errors/expected/primitives10.re.expected

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
1 │ let aaaaa = 10;
66
2 │ let b = aaaab;
7+
3 │
78

89
The value aaaab can't be found
910

‎jscomp/build_tests/super_errors/expected/primitives2.re.expected

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
1 │ /* got int, wanted string */
66
2 │ 2 ++ " things";
7+
3 │
78

89
This has type: int
910
Somewhere wanted: string

‎jscomp/build_tests/super_errors/expected/primitives3.re.expected

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
1 │ /* Too many arguments */
66
2 │ let x = (a) => a + 2;
77
3 │ x(2, 4);
8+
4 │
89

910
This function has type int => int
1011
It only accepts 1 argument; here, it's called with more.

‎jscomp/build_tests/super_errors/expected/primitives4.re.expected

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
1 │ /* Not a function */
66
2 │ let x = 10;
77
3 │ x(10);
8+
4 │
89

910
This expression has type int
1011
It is not a function.

‎jscomp/build_tests/super_errors/expected/primitives5.re.expected

+1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55
1 │ /* Not enough arguments */
66
2 │ type x = X(int, float);
77
3 │ X(10) -> ignore;
8+
4 │
89

910
This variant constructor, X, expects 2 arguments; here, we've only found 1.

‎jscomp/build_tests/super_errors/expected/primitives6.re.expected

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
1 │ /* Wrong constructor argument */
66
2 │ type x = X(int, float);
77
3 │ X(10, 10) -> ignore;
8+
4 │
89

910
This has type: int
1011
Somewhere wanted: float

‎jscomp/build_tests/super_errors/expected/primitives7.re.expected

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
1 │ /* Wanted list(float), found list(int) */
66
2 │ let a = [1,2,3];
77
3 │ List.map(((n) => n +. 2.), a);
8+
4 │
89

910
This has type: list(int)
1011
Somewhere wanted: list(float)

‎jscomp/build_tests/super_errors/expected/primitives8.re.expected

+1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
/.../fixtures/primitives8.re:1:11-13
44

55
1 │ let asd = aaa;
6+
2 │
67

78
The value aaa can't be found

‎jscomp/build_tests/super_errors/expected/primitives9.re.expected

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
/.../fixtures/primitives9.re:1:14-20
44

55
1 │ let a: int = "hello"
6+
2 │
67

78
This has type: string
89
Somewhere wanted: int

‎jscomp/build_tests/super_errors/expected/type1.re.expected

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
/.../fixtures/type1.re:1:9-10
44

55
1 │ let x = 2. + 2;
6+
2 │
67

78
This has type: float
89
Somewhere wanted: int

‎jscomp/build_tests/super_errors/expected/warnings3.re.expected

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Please use Js.Float.toString instead, string_of_float generates unparseable floa
1616
1 │ let _ = string_of_float(34.)
1717
2 │ let _ = string_of_float(34.)
1818
3 │ let _ = string_of_float(34.)
19+
4 │
1920

2021
deprecated: Pervasives.string_of_float
2122
Please use Js.Float.toString instead, string_of_float generates unparseable floats
@@ -27,6 +28,7 @@ Please use Js.Float.toString instead, string_of_float generates unparseable floa
2728
1 │ let _ = string_of_float(34.)
2829
2 │ let _ = string_of_float(34.)
2930
3 │ let _ = string_of_float(34.)
31+
4 │
3032

3133
deprecated: Pervasives.string_of_float
3234
Please use Js.Float.toString instead, string_of_float generates unparseable floats

‎jscomp/super_errors/super_code_frame.ml

-10
Original file line numberDiff line numberDiff line change
@@ -162,16 +162,6 @@ let print ~is_warning ~src ~startPos ~endPos =
162162
let lines =
163163
(* TODO: off-by-one danger *)
164164
String.sub src start_line_line_offset (end_line_line_end_offset - start_line_line_offset)
165-
in
166-
(* TODO: remove this after the next PR *)
167-
let len = String.length lines in
168-
let lines =
169-
if len > 1 && (String.get src (len - 1)) = '\n' then
170-
String.sub lines 0 (len - 1)
171-
else
172-
lines
173-
in
174-
let lines = lines
175165
|> String.split_on_char '\n'
176166
|> filter_mapi (fun i line ->
177167
let line_number = i + first_shown_line in

‎lib/4.06.1/unstable/js_compiler.ml

-10
Original file line numberDiff line numberDiff line change
@@ -407577,16 +407577,6 @@ let print ~is_warning ~src ~startPos ~endPos =
407577407577
let lines =
407578407578
(* TODO: off-by-one danger *)
407579407579
String.sub src start_line_line_offset (end_line_line_end_offset - start_line_line_offset)
407580-
in
407581-
(* TODO: remove this after the next PR *)
407582-
let len = String.length lines in
407583-
let lines =
407584-
if len > 1 && (String.get src (len - 1)) = '\n' then
407585-
String.sub lines 0 (len - 1)
407586-
else
407587-
lines
407588-
in
407589-
let lines = lines
407590407580
|> String.split_on_char '\n'
407591407581
|> filter_mapi (fun i line ->
407592407582
let line_number = i + first_shown_line in

‎lib/4.06.1/whole_compiler.ml

-10
Original file line numberDiff line numberDiff line change
@@ -433628,16 +433628,6 @@ let print ~is_warning ~src ~startPos ~endPos =
433628433628
let lines =
433629433629
(* TODO: off-by-one danger *)
433630433630
String.sub src start_line_line_offset (end_line_line_end_offset - start_line_line_offset)
433631-
in
433632-
(* TODO: remove this after the next PR *)
433633-
let len = String.length lines in
433634-
let lines =
433635-
if len > 1 && (String.get src (len - 1)) = '\n' then
433636-
String.sub lines 0 (len - 1)
433637-
else
433638-
lines
433639-
in
433640-
let lines = lines
433641433631
|> String.split_on_char '\n'
433642433632
|> filter_mapi (fun i line ->
433643433633
let line_number = i + first_shown_line in

0 commit comments

Comments
 (0)