January 13, 2019
On Saturday, 12 January 2019 at 15:34:02 UTC, Seb wrote:
> Full changelog: https://dlang.org/changelog/pending.html#error-context
> Play online: https://run.dlang.io/is/8gsye1
>
> Thanks to all the people (Jacob Carlborg, Petar Kirov, Nicolas Wilson, Rainer Schuetze, etc.) who helped me to get this feature into DMD!

Wonderful!

Have you looked at my previous proposal at https://wiki.dlang.org/DIP83?

Thanks a lot!
January 13, 2019
On Sunday, 13 January 2019 at 09:48:53 UTC, Per Nordlöw wrote:
>
> Have you looked at my previous proposal at https://wiki.dlang.org/DIP83?

Yes of course ;-) (and it was one of the main inspirations for this work).
Please see the DMD PR for the full history of this feature, discussion and the implementation in DMD:

https://github.com/dlang/dmd/pull/8517
January 13, 2019
On Saturday, 12 January 2019 at 15:34:02 UTC, Seb wrote:
> https://dlang.org/changelog/pending.html#error-context
> Play online: https://run.dlang.io/is/8gsye1

Is there a way to download a dmd nightly and try this out?

The nightly at https://dlang.org/download.html is currently broken.
January 13, 2019
On Sunday, 13 January 2019 at 11:11:05 UTC, Per Nordlöw wrote:
> On Saturday, 12 January 2019 at 15:34:02 UTC, Seb wrote:
>> https://dlang.org/changelog/pending.html#error-context
>> Play online: https://run.dlang.io/is/8gsye1
>
> Is there a way to download a dmd nightly and try this out?

e.g. https://run.dlang.io/is/GMfe9S for playing online with it.

or:

curl https://dlang.org/install.sh | bash -s dmd-nightly

> The nightly at https://dlang.org/download.html is currently broken.

The link just uses HTTPS which isn't supported by the S3 bucket.
HTTP works: HTTP works: http://downloads.dlang.org/nightlies/

See also: https://github.com/dlang/dlang.org/pull/2554

Alternatively, you could always use digger:


---
dub fetch digger
dub run digger -- build
---

(this will build the current master of DMD/Druntime/Phobos/Tools/Dub automatically for you)
January 13, 2019
On Sunday, 13 January 2019 at 12:01:49 UTC, Seb wrote:
> The link just uses HTTPS which isn't supported by the S3 bucket.
> HTTP works: HTTP works: http://downloads.dlang.org/nightlies/
>
> See also: https://github.com/dlang/dlang.org/pull/2554
>
> Alternatively, you could always use digger:
>
> ---
> dub fetch digger
> dub run digger -- build
> ---
>
> (this will build the current master of DMD/Druntime/Phobos/Tools/Dub automatically for you)

Thanks!
January 13, 2019
On Saturday, 12 January 2019 at 15:34:02 UTC, Seb wrote:
> Thanks to all the people (Jacob Carlborg, Petar Kirov, Nicolas Wilson, Rainer Schuetze, etc.) who helped me to get this feature into DMD!
>
> Merry Christmas!

Awesome, thank you! This should be great for debug builds.
January 14, 2019
On Saturday, 12 January 2019 at 15:34:02 UTC, Seb wrote:
> tl;dr: I was annoyed for years that D's assert are so non informative AssertError, so here's my late Christmas present for the D community. With 2.085 DMD will gain an experimental flag for more informative assertion errors. Feedback on this experimental feature is welcome, s.t. we eventually can enable it by default.
>
> [...]

Awesome.

It's obvious that assertions for equality are the most common, I wonder how easy it would be to get other changes merged like `assert(foo in bar)`. There are also all the assertions that make use of `equal` because of ranges. In unit-threaded `foo.should == bar` works if foo is a range and bar is a dynamic array.

What I'd really like is access to the AST in the assert but alas I don't think that will ever be possible.
January 14, 2019
On Monday, 14 January 2019 at 14:15:45 UTC, Atila Neves wrote:
> On Saturday, 12 January 2019 at 15:34:02 UTC, Seb wrote:
>> tl;dr: I was annoyed for years that D's assert are so non informative AssertError, so here's my late Christmas present for the D community. With 2.085 DMD will gain an experimental flag for more informative assertion errors. Feedback on this experimental feature is welcome, s.t. we eventually can enable it by default.
>>
>> [...]
>
> Awesome.
>
> It's obvious that assertions for equality are the most common, I wonder how easy it would be to get other changes merged like `assert(foo in bar)`.

Should be easy enough:

https://github.com/dlang/dmd/pull/9264
https://github.com/dlang/druntime/pull/2463

Also note that other trivial stuff like `a < b` is already supported.
See e.g.: https://github.com/dlang/druntime/blob/master/test/exceptions/src/assert_fail.d

> There are also all the assertions that make use of `equal` because of ranges.

In theory we could hard-code a check for the symbol in DMD and see whether its std.algorithm.comparison.equal, but ranges are tricky as both might have been consumed by `equal` and you would then end up printing e.g. sth. like:

[] != []

> I'd really like is access to the AST in the assert but alas I don't think that will ever be possible.

Yeah :/
January 14, 2019
On 1/12/19 10:34 AM, Seb wrote:
> tl;dr: I was annoyed for years that D's assert are so non informative AssertError, so here's my late Christmas present for the D community. With 2.085 DMD will gain an experimental flag for more informative assertion errors. Feedback on this experimental feature is welcome, s.t. we eventually can enable it by default.
> 
> Example:
> 
> ---
> void main()
> {
>      int a = 1, b = 2;
>      assert(a == b); // ERROR: 1 != 2
> }
> ---
> 
> ```
>> dmd -run onlineapp.d
> core.exception.AssertError@onlineapp.d(4): 1 != 2

Wonderful. Thanks!

January 14, 2019
On Saturday, 12 January 2019 at 16:52:28 UTC, Seb wrote:
> On Saturday, 12 January 2019 at 16:32:43 UTC, H. S. Teoh wrote:
>>
>> Seriously, for editor/IDE plugins, there should be a --porcelain option that outputs error messages in a machine-friendly format, like with a fixed format that's easy for scripts / code / whatever to parse.
>>
>>
>> T
>
> It probably would be -verrors=json (or sth. like this), but the problem is that tools which parse DMD output are already out there, so we need to be a bit careful not to break them.
>
> Anyhow, I think using TTY detection to enable -verrors=context by default should work fine.
> DMD did/does the same when color-coded messages (`-color` ) where introduced.

I would be happy to change code-d and tools to any other format than currently parsing regexes, it's also missing consecutive errors like "instantiated from here" right now which I would like to fix :)