Skip to content

Commit

Permalink
feat(errors): make verrors=context global and update test outputs
Browse files Browse the repository at this point in the history
Signed-off-by: royalpinto007 <[email protected]>
  • Loading branch information
royalpinto007 committed Nov 23, 2024
1 parent 36c58b7 commit 0081e4e
Show file tree
Hide file tree
Showing 1,507 changed files with 14,393 additions and 5,158 deletions.
2 changes: 2 additions & 0 deletions compiler/src/dmd/globals.d
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,8 @@ extern (C++) struct Global
params.v.color = detectTerminal();
}

params.v.printErrorContext = true; // Enable error context globally by default

compileEnv.versionNumber = parseVersionNumber(versionString());

/* Initialize date, time, and timestamp
Expand Down
4 changes: 4 additions & 0 deletions compiler/src/dmd/mars.d
Original file line number Diff line number Diff line change
Expand Up @@ -1008,6 +1008,10 @@ bool parseCommandLine(const ref Strings arguments, const size_t argc, ref Param
{
params.v.printErrorContext = true;
}
else if (startsWith(p + 9, "none"))
{
params.v.printErrorContext = false; // Disable error context
}
else if (!params.v.errorLimit.parseDigits(p.toDString()[9 .. $]))
{
errorInvalidSwitch(p, "Only number, `spec`, or `context` are allowed for `-verrors`");
Expand Down
80 changes: 60 additions & 20 deletions compiler/test/compilable/b16976.d
Original file line number Diff line number Diff line change
@@ -1,26 +1,66 @@
/* REQUIRED_ARGS: -m64
TEST_OUTPUT:
---
compilable/b16976.d(33): Deprecation: foreach: loop index implicitly converted from `size_t` to `int`
compilable/b16976.d(34): Deprecation: foreach: loop index implicitly converted from `size_t` to `int`
compilable/b16976.d(35): Deprecation: foreach: loop index implicitly converted from `size_t` to `char`
compilable/b16976.d(36): Deprecation: foreach: loop index implicitly converted from `size_t` to `char`
compilable/b16976.d(41): Deprecation: foreach: loop index implicitly converted from `size_t` to `int`
compilable/b16976.d(42): Deprecation: foreach: loop index implicitly converted from `size_t` to `int`
compilable/b16976.d(43): Deprecation: foreach: loop index implicitly converted from `size_t` to `char`
compilable/b16976.d(44): Deprecation: foreach: loop index implicitly converted from `size_t` to `char`
compilable/b16976.d(50): Deprecation: foreach: loop index implicitly converted from `size_t` to `int`
compilable/b16976.d(51): Deprecation: foreach: loop index implicitly converted from `size_t` to `int`
compilable/b16976.d(52): Deprecation: foreach: loop index implicitly converted from `size_t` to `char`
compilable/b16976.d(53): Deprecation: foreach: loop index implicitly converted from `size_t` to `char`
compilable/b16976.d(58): Deprecation: foreach: loop index implicitly converted from `size_t` to `int`
compilable/b16976.d(59): Deprecation: foreach: loop index implicitly converted from `size_t` to `int`
compilable/b16976.d(60): Deprecation: foreach: loop index implicitly converted from `size_t` to `char`
compilable/b16976.d(61): Deprecation: foreach: loop index implicitly converted from `size_t` to `char`
compilable/b16976.d(62): Deprecation: foreach: loop index implicitly converted from `size_t` to `int`
compilable/b16976.d(63): Deprecation: foreach: loop index implicitly converted from `size_t` to `int`
compilable/b16976.d(64): Deprecation: foreach: loop index implicitly converted from `size_t` to `char`
compilable/b16976.d(65): Deprecation: foreach: loop index implicitly converted from `size_t` to `char`
compilable/b16976.d(73): Deprecation: foreach: loop index implicitly converted from `size_t` to `int`
foreach(int i, v; dyn) { }
^
compilable/b16976.d(74): Deprecation: foreach: loop index implicitly converted from `size_t` to `int`
foreach_reverse(int i, v; dyn) { }
^
compilable/b16976.d(75): Deprecation: foreach: loop index implicitly converted from `size_t` to `char`
foreach(char i, v; dyn) { }
^
compilable/b16976.d(76): Deprecation: foreach: loop index implicitly converted from `size_t` to `char`
foreach_reverse(char i, v; dyn) { }
^
compilable/b16976.d(81): Deprecation: foreach: loop index implicitly converted from `size_t` to `int`
foreach(int i, v; str) { }
^
compilable/b16976.d(82): Deprecation: foreach: loop index implicitly converted from `size_t` to `int`
foreach_reverse(int i, v; str) { }
^
compilable/b16976.d(83): Deprecation: foreach: loop index implicitly converted from `size_t` to `char`
foreach(char i, v; str) { }
^
compilable/b16976.d(84): Deprecation: foreach: loop index implicitly converted from `size_t` to `char`
foreach_reverse(char i, v; str) { }
^
compilable/b16976.d(90): Deprecation: foreach: loop index implicitly converted from `size_t` to `int`
foreach(int i, dchar v; dyn) { }
^
compilable/b16976.d(91): Deprecation: foreach: loop index implicitly converted from `size_t` to `int`
foreach_reverse(int i, dchar v; dyn) { }
^
compilable/b16976.d(92): Deprecation: foreach: loop index implicitly converted from `size_t` to `char`
foreach(char i, dchar v; dyn) { }
^
compilable/b16976.d(93): Deprecation: foreach: loop index implicitly converted from `size_t` to `char`
foreach_reverse(char i, dchar v; dyn) { }
^
compilable/b16976.d(98): Deprecation: foreach: loop index implicitly converted from `size_t` to `int`
foreach(int i, dchar v; str) { }
^
compilable/b16976.d(99): Deprecation: foreach: loop index implicitly converted from `size_t` to `int`
foreach_reverse(int i, dchar v; str) { }
^
compilable/b16976.d(100): Deprecation: foreach: loop index implicitly converted from `size_t` to `char`
foreach(char i, dchar v; str) { }
^
compilable/b16976.d(101): Deprecation: foreach: loop index implicitly converted from `size_t` to `char`
foreach_reverse(char i, dchar v; str) { }
^
compilable/b16976.d(102): Deprecation: foreach: loop index implicitly converted from `size_t` to `int`
foreach(int i, dchar v; chr) { }
^
compilable/b16976.d(103): Deprecation: foreach: loop index implicitly converted from `size_t` to `int`
foreach_reverse(int i, dchar v; chr) { }
^
compilable/b16976.d(104): Deprecation: foreach: loop index implicitly converted from `size_t` to `char`
foreach(char i, dchar v; chr) { }
^
compilable/b16976.d(105): Deprecation: foreach: loop index implicitly converted from `size_t` to `char`
foreach_reverse(char i, dchar v; chr) { }
^
---
*/
void main()
Expand Down
4 changes: 3 additions & 1 deletion compiler/test/compilable/chkformat.d
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
/*
TEST_OUTPUT:
----
compilable/chkformat.d(14): Deprecation: more format specifiers than 0 arguments
compilable/chkformat.d(16): Deprecation: more format specifiers than 0 arguments
printf("%d \n");
^
----
*/
import core.stdc.stdio;
Expand Down
4 changes: 3 additions & 1 deletion compiler/test/compilable/compile1.d
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
// EXTRA_FILES: imports/a12506.d
/* TEST_OUTPUT:
---
compilable/compile1.d(230): Deprecation: use of complex type `cdouble` is deprecated, use `std.complex.Complex!(double)` instead
compilable/compile1.d(232): Deprecation: use of complex type `cdouble` is deprecated, use `std.complex.Complex!(double)` instead
cdouble c6096;
^
---
*/

Expand Down
22 changes: 16 additions & 6 deletions compiler/test/compilable/ddoc10236.d
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,22 @@
/*
TEST_OUTPUT:
---
compilable/ddoc10236.d(35): Warning: Ddoc: parameter count mismatch, expected 2, got 1
compilable/ddoc10236.d(47): Warning: Ddoc: function declaration has no parameter 'y'
compilable/ddoc10236.d(59): Warning: Ddoc: function declaration has no parameter 'y'
compilable/ddoc10236.d(59): Warning: Ddoc: parameter count mismatch, expected 1, got 2
compilable/ddoc10236.d(71): Warning: Ddoc: parameter count mismatch, expected 2, got 0
compilable/ddoc10236.d(71): Note that the format is `param = description`
compilable/ddoc10236.d(45): Warning: Ddoc: parameter count mismatch, expected 2, got 1
void foo_count_mismatch(int x, int y) // Warning: Ddoc: parameter count mismatch
^
compilable/ddoc10236.d(57): Warning: Ddoc: function declaration has no parameter 'y'
void foo_no_param_y(int x, int z) // Warning: Ddoc: function declaration has no parameter 'y'
^
compilable/ddoc10236.d(69): Warning: Ddoc: function declaration has no parameter 'y'
void foo_count_mismatch_no_param_y(int x)
^
compilable/ddoc10236.d(69): Warning: Ddoc: parameter count mismatch, expected 1, got 2
void foo_count_mismatch_no_param_y(int x)
^
compilable/ddoc10236.d(81): Warning: Ddoc: parameter count mismatch, expected 2, got 0
void foo_count_mismatch_wrong_format(int x, int y)
^
compilable/ddoc10236.d(81): Note that the format is `param = description`
---
*/

Expand Down
18 changes: 13 additions & 5 deletions compiler/test/compilable/ddoc10236b.d
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,19 @@
/*
TEST_OUTPUT:
---
compilable/ddoc10236b.d(44): Warning: Ddoc: parameter count mismatch, expected 1, got 0
compilable/ddoc10236b.d(44): Note that the format is `param = description`
compilable/ddoc10236b.d(56): Warning: Ddoc: function declaration has no parameter 'y'
compilable/ddoc10236b.d(68): Warning: Ddoc: function declaration has no parameter 'y'
compilable/ddoc10236b.d(68): Warning: Ddoc: parameter count mismatch, expected 0, got 1
compilable/ddoc10236b.d(52): Warning: Ddoc: parameter count mismatch, expected 1, got 0
void foo_count_mismatch(int x)(int y) // Warning: Ddoc: parameter count mismatch
^
compilable/ddoc10236b.d(52): Note that the format is `param = description`
compilable/ddoc10236b.d(64): Warning: Ddoc: function declaration has no parameter 'y'
void foo_no_param_y(int x)(int z) // Warning: Ddoc: function declaration has no parameter 'y'
^
compilable/ddoc10236b.d(76): Warning: Ddoc: function declaration has no parameter 'y'
void foo_count_mismatch_no_param_y(int x)()
^
compilable/ddoc10236b.d(76): Warning: Ddoc: parameter count mismatch, expected 0, got 1
void foo_count_mismatch_no_param_y(int x)()
^
---
*/

Expand Down
16 changes: 12 additions & 4 deletions compiler/test/compilable/ddoc13502.d
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,18 @@
/*
TEST_OUTPUT:
---
compilable/ddoc13502.d(14): Warning: Ddoc: Stray '('. This may cause incorrect Ddoc output. Use $(LPAREN) instead for unpaired left parentheses.
compilable/ddoc13502.d(17): Warning: Ddoc: Stray '('. This may cause incorrect Ddoc output. Use $(LPAREN) instead for unpaired left parentheses.
compilable/ddoc13502.d(21): Warning: Ddoc: Stray '('. This may cause incorrect Ddoc output. Use $(LPAREN) instead for unpaired left parentheses.
compilable/ddoc13502.d(24): Warning: Ddoc: Stray '('. This may cause incorrect Ddoc output. Use $(LPAREN) instead for unpaired left parentheses.
compilable/ddoc13502.d(22): Warning: Ddoc: Stray '('. This may cause incorrect Ddoc output. Use $(LPAREN) instead for unpaired left parentheses.
enum isSomeString(T) = true;
^
compilable/ddoc13502.d(25): Warning: Ddoc: Stray '('. This may cause incorrect Ddoc output. Use $(LPAREN) instead for unpaired left parentheses.
enum bool isArray(T) = true;
^
compilable/ddoc13502.d(29): Warning: Ddoc: Stray '('. This may cause incorrect Ddoc output. Use $(LPAREN) instead for unpaired left parentheses.
extern(C) alias int T1;
^
compilable/ddoc13502.d(32): Warning: Ddoc: Stray '('. This may cause incorrect Ddoc output. Use $(LPAREN) instead for unpaired left parentheses.
extern(C) alias T2 = int;
^
---
*/

Expand Down
52 changes: 39 additions & 13 deletions compiler/test/compilable/depmsg.d
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,45 @@
REQUIRED_ARGS: -dw
TEST_OUTPUT:
---
compilable/depmsg.d(39): Deprecation: struct `depmsg.main.Inner.A` is deprecated - With message!
compilable/depmsg.d(39): Deprecation: struct `depmsg.main.Inner.A` is deprecated - With message!
compilable/depmsg.d(40): Deprecation: class `depmsg.main.Inner.B` is deprecated - With message!
compilable/depmsg.d(40): Deprecation: class `depmsg.main.Inner.B` is deprecated - With message!
compilable/depmsg.d(41): Deprecation: interface `depmsg.main.Inner.C` is deprecated - With message!
compilable/depmsg.d(41): Deprecation: interface `depmsg.main.Inner.C` is deprecated - With message!
compilable/depmsg.d(42): Deprecation: union `depmsg.main.Inner.D` is deprecated - With message!
compilable/depmsg.d(42): Deprecation: union `depmsg.main.Inner.D` is deprecated - With message!
compilable/depmsg.d(43): Deprecation: enum `depmsg.main.Inner.E` is deprecated - With message!
compilable/depmsg.d(43): Deprecation: enum `depmsg.main.Inner.E` is deprecated - With message!
compilable/depmsg.d(45): Deprecation: alias `depmsg.main.Inner.G` is deprecated - With message!
compilable/depmsg.d(46): Deprecation: variable `depmsg.main.Inner.H` is deprecated - With message!
compilable/depmsg.d(47): Deprecation: class `depmsg.main.Inner.I()` is deprecated - With message!
compilable/depmsg.d(65): Deprecation: struct `depmsg.main.Inner.A` is deprecated - With message!
A a;
^
compilable/depmsg.d(65): Deprecation: struct `depmsg.main.Inner.A` is deprecated - With message!
A a;
^
compilable/depmsg.d(66): Deprecation: class `depmsg.main.Inner.B` is deprecated - With message!
B b;
^
compilable/depmsg.d(66): Deprecation: class `depmsg.main.Inner.B` is deprecated - With message!
B b;
^
compilable/depmsg.d(67): Deprecation: interface `depmsg.main.Inner.C` is deprecated - With message!
C c;
^
compilable/depmsg.d(67): Deprecation: interface `depmsg.main.Inner.C` is deprecated - With message!
C c;
^
compilable/depmsg.d(68): Deprecation: union `depmsg.main.Inner.D` is deprecated - With message!
D d;
^
compilable/depmsg.d(68): Deprecation: union `depmsg.main.Inner.D` is deprecated - With message!
D d;
^
compilable/depmsg.d(69): Deprecation: enum `depmsg.main.Inner.E` is deprecated - With message!
E e;
^
compilable/depmsg.d(69): Deprecation: enum `depmsg.main.Inner.E` is deprecated - With message!
E e;
^
compilable/depmsg.d(71): Deprecation: alias `depmsg.main.Inner.G` is deprecated - With message!
G g;
^
compilable/depmsg.d(72): Deprecation: variable `depmsg.main.Inner.H` is deprecated - With message!
auto h = H;
^
compilable/depmsg.d(73): Deprecation: class `depmsg.main.Inner.I()` is deprecated - With message!
I!() i;
^
---
*/
void main()
Expand Down
12 changes: 9 additions & 3 deletions compiler/test/compilable/deprecationlimit.d
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@
REQUIRED_ARGS: -verrors=3
TEST_OUTPUT:
---
compilable/deprecationlimit.d(18): Deprecation: function `deprecationlimit.f` is deprecated
compilable/deprecationlimit.d(19): Deprecation: function `deprecationlimit.f` is deprecated
compilable/deprecationlimit.d(20): Deprecation: function `deprecationlimit.f` is deprecated
compilable/deprecationlimit.d(24): Deprecation: function `deprecationlimit.f` is deprecated
f();
^
compilable/deprecationlimit.d(25): Deprecation: function `deprecationlimit.f` is deprecated
f();
^
compilable/deprecationlimit.d(26): Deprecation: function `deprecationlimit.f` is deprecated
f();
^
1 deprecation warning omitted, use `-verrors=0` to show all
---
*/
Expand Down
4 changes: 3 additions & 1 deletion compiler/test/compilable/interpret3.d
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
/*
TEST_OUTPUT:
---
compilable/interpret3.d(6350): Deprecation: identity comparison of static arrays implicitly coerces them to slices, which are compared by reference
compilable/interpret3.d(6352): Deprecation: identity comparison of static arrays implicitly coerces them to slices, which are compared by reference
assert(b is b);
^
---
*/

Expand Down
4 changes: 3 additions & 1 deletion compiler/test/compilable/test12567c.d
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
/*
TEST_OUTPUT:
---
compilable/test12567c.d(10): Deprecation: module `imports.a12567` is deprecated - This module will be removed in future release.
compilable/test12567c.d(12): Deprecation: module `imports.a12567` is deprecated - This module will be removed in future release.
import imports.a12567;
^
---
*/
import imports.a12567;
Expand Down
4 changes: 3 additions & 1 deletion compiler/test/compilable/test19227.d
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// https://issues.dlang.org/show_bug.cgi?id=19227
/* TEST_OUTPUT:
---
compilable/test19227.d(18): Deprecation: use of complex type `cfloat` is deprecated, use `std.complex.Complex!(float)` instead
compilable/test19227.d(20): Deprecation: use of complex type `cfloat` is deprecated, use `std.complex.Complex!(float)` instead
cfloat cf;
^
Deprecation: use of complex type `const(cfloat)` is deprecated, use `std.complex.Complex!(float)` instead
Deprecation: use of complex type `const(cfloat)` is deprecated, use `std.complex.Complex!(float)` instead
Deprecation: use of complex type `const(cfloat)` is deprecated, use `std.complex.Complex!(float)` instead
Expand Down
12 changes: 9 additions & 3 deletions compiler/test/compilable/test19609.d
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,15 @@
/*
TEST_OUTPUT:
---
compilable/test19609.d(11): Deprecation: module `imports.test19609a` is deprecated
compilable/test19609.d(12): Deprecation: module `imports.test19609b` is deprecated - hello
compilable/test19609.d(13): Deprecation: module `imports.test19609c` is deprecated
compilable/test19609.d(17): Deprecation: module `imports.test19609a` is deprecated
import imports.test19609a;
^
compilable/test19609.d(18): Deprecation: module `imports.test19609b` is deprecated - hello
import imports.test19609b;
^
compilable/test19609.d(19): Deprecation: module `imports.test19609c` is deprecated
import imports.test19609c;
^
---
*/
import imports.test19609a;
Expand Down
8 changes: 6 additions & 2 deletions compiler/test/compilable/test20063.d
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
/* TEST_OUTPUT:
---
compilable/test20063.d(10): Deprecation: function `test20063.main.f!(delegate () pure nothrow @safe => new C).f` function requires a dual-context, which is deprecated
compilable/test20063.d(19): instantiated from here: `f!(delegate () pure nothrow @safe => new C)`
compilable/test20063.d(14): Deprecation: function `test20063.main.f!(delegate () pure nothrow @safe => new C).f` function requires a dual-context, which is deprecated
void f(alias fun)() {}
^
compilable/test20063.d(23): instantiated from here: `f!(delegate () pure nothrow @safe => new C)`
S().f!(() => new C()).handleLazily;
^
---
*/

Expand Down
32 changes: 24 additions & 8 deletions compiler/test/compilable/test21514.d
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,30 @@
// DISABLED: win32 win64
/* TEST_OUTPUT:
---
compilable/test21514.d(16): Deprecation: use of complex type `cdouble` is deprecated, use `std.complex.Complex!(double)` instead
compilable/test21514.d(16): Deprecation: use of complex type `cdouble` is deprecated, use `std.complex.Complex!(double)` instead
compilable/test21514.d(17): Deprecation: use of complex type `creal` is deprecated, use `std.complex.Complex!(real)` instead
compilable/test21514.d(17): Deprecation: use of complex type `creal` is deprecated, use `std.complex.Complex!(real)` instead
compilable/test21514.d(19): Deprecation: use of complex type `cdouble` is deprecated, use `std.complex.Complex!(double)` instead
compilable/test21514.d(19): Deprecation: use of complex type `cdouble` is deprecated, use `std.complex.Complex!(double)` instead
compilable/test21514.d(20): Deprecation: use of complex type `creal` is deprecated, use `std.complex.Complex!(real)` instead
compilable/test21514.d(20): Deprecation: use of complex type `creal` is deprecated, use `std.complex.Complex!(real)` instead
compilable/test21514.d(32): Deprecation: use of complex type `cdouble` is deprecated, use `std.complex.Complex!(double)` instead
extern(C++) cdouble cpp_cadd1(cdouble c) { return c + 1; }
^
compilable/test21514.d(32): Deprecation: use of complex type `cdouble` is deprecated, use `std.complex.Complex!(double)` instead
extern(C++) cdouble cpp_cadd1(cdouble c) { return c + 1; }
^
compilable/test21514.d(33): Deprecation: use of complex type `creal` is deprecated, use `std.complex.Complex!(real)` instead
extern(C++) creal cpp_cadd1l(creal c) { return c + 1; }
^
compilable/test21514.d(33): Deprecation: use of complex type `creal` is deprecated, use `std.complex.Complex!(real)` instead
extern(C++) creal cpp_cadd1l(creal c) { return c + 1; }
^
compilable/test21514.d(35): Deprecation: use of complex type `cdouble` is deprecated, use `std.complex.Complex!(double)` instead
cdouble cadd1(cdouble c) { return cpp_cadd1(c); }
^
compilable/test21514.d(35): Deprecation: use of complex type `cdouble` is deprecated, use `std.complex.Complex!(double)` instead
cdouble cadd1(cdouble c) { return cpp_cadd1(c); }
^
compilable/test21514.d(36): Deprecation: use of complex type `creal` is deprecated, use `std.complex.Complex!(real)` instead
creal cadd1(creal c) { return cpp_cadd1l(c); }
^
compilable/test21514.d(36): Deprecation: use of complex type `creal` is deprecated, use `std.complex.Complex!(real)` instead
creal cadd1(creal c) { return cpp_cadd1l(c); }
^
---
*/

Expand Down
Loading

0 comments on commit 0081e4e

Please sign in to comment.