Thread overview
[Issue 8765] assert should print the source code for the condition when no message argument present
Jun 19, 2014
Walter Bright
Jun 19, 2014
Walter Bright
Oct 11, 2015
Andrej Mitrovic
Oct 11, 2015
Andrej Mitrovic
Feb 03, 2018
Timothee Cour
Sep 08, 2022
RazvanN
June 19, 2014
https://issues.dlang.org/show_bug.cgi?id=8765

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@digitalmars.com

--- Comment #10 from Walter Bright <bugzilla@digitalmars.com> ---
(In reply to bearophile_hugs from comment #3)
> It gives me:
> 
> core.exception.AssertError@test(2): Assertion failure
> 
> Followed by a stack trace.

I don't get it - what's the problem?

--
June 19, 2014
https://issues.dlang.org/show_bug.cgi?id=8765

--- Comment #11 from Walter Bright <bugzilla@digitalmars.com> ---
(In reply to Val Markovic from comment #0)
> Currently I just get "unittest failure" instead of the condition source, which is useless.

It gives the file/line, which is not useless:

1. editors, IDEs, etc., can take you right to the source code of the error

2. assert checks can add a great deal of bloat to the executable - the current implementation tries to minimize that. Adding expression strings to all of them will dramatically increase the size of an executable

I just do not understand why file/line is not sufficient.

--
October 11, 2015
https://issues.dlang.org/show_bug.cgi?id=8765

--- Comment #12 from Andrej Mitrovic <andrej.mitrovich@gmail.com> ---
(In reply to Walter Bright from comment #11)
> (In reply to Val Markovic from comment #0)
> > Currently I just get "unittest failure" instead of the condition source, which is useless.
> 
> It gives the file/line, which is not useless:
> 
> 1. editors, IDEs, etc., can take you right to the source code of the error
> 
> 2. assert checks can add a great deal of bloat to the executable - the current implementation tries to minimize that. Adding expression strings to all of them will dramatically increase the size of an executable
> 
> I just do not understand why file/line is not sufficient.

If the assert is triggered at runtime in a realtime application you want to make sure you get the relevant information back to you as soon as possible. You may not even have the source at hand, it would really help knowing what condition failed.

Code bloat is an issue, but if the requirement is a minimal binary then it would be safe to assume -release is implied, no? So the asserts wouldn't be compiled in anywho.

In any case I'll work on this PR again.

--
October 11, 2015
https://issues.dlang.org/show_bug.cgi?id=8765

Andrej Mitrovic <andrej.mitrovich@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                URL|                            |https://github.com/D-Progra
                   |                            |mming-Language/dmd/pull/518
                   |                            |9

--
February 03, 2018
https://issues.dlang.org/show_bug.cgi?id=8765

Timothee Cour <timothee.cour2@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |timothee.cour2@gmail.com

--- Comment #13 from Timothee Cour <timothee.cour2@gmail.com> ---
my PR solves exactly this problem but in a more general way: https://github.com/dlang/dmd/pull/7821

--
November 05, 2021
https://issues.dlang.org/show_bug.cgi?id=8765

moonlightsentinel@disroot.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |moonlightsentinel@disroot.o
                   |                            |rg

--- Comment #14 from moonlightsentinel@disroot.org ---
Meanwhile `-checkaction=context` exists which will print the failing expression using the actual values instead of the plain source code. Can this be closed?

--
September 08, 2022
https://issues.dlang.org/show_bug.cgi?id=8765

RazvanN <razvan.nitu1305@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |razvan.nitu1305@gmail.com
         Resolution|---                         |FIXED

--- Comment #15 from RazvanN <razvan.nitu1305@gmail.com> ---
Yes, this has been fixed by: https://github.com/dlang/dmd/pull/8517

--