D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 10278 - Pre-condition failure blame error message to improve debugging
Summary: Pre-condition failure blame error message to improve debugging
Status: RESOLVED WONTFIX
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 enhancement
Assignee: No Owner
URL:
Keywords: diagnostic
Depends on:
Blocks:
 
Reported: 2013-06-05 17:16 UTC by bearophile_hugs
Modified: 2021-05-11 09:12 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description bearophile_hugs 2013-06-05 17:16:18 UTC
int foo(int x)
in {
    assert(x >= 0); // line 3.
} body {
    return x ^^ 2;
}
void main() {
    foo(-1); // line 8.
}


With DMD 2.064alpha it gives at run-time:

core.exception.AssertError@temp(3): Assertion failure

followed by the stack trace.


To speed up my debugging I suggest to instead generate two error messages similar to (the second line is the same as before):

temp.d(8): Pre-condition violation: x >= 0  (x = -1)
core.exception.AssertError@temp(3): Assertion failure
Comment 1 RazvanN 2021-05-11 09:12:26 UTC
This seems to add little benefit as the stack trace contains the line numbers.