Use assert instead of enforce in std.numeric#4688
Conversation
std/numeric.d
Outdated
| // No infinity support? | ||
| enforce(sig != 0, "Infinity floating point value assigned to a " | ||
| ~ typeof(this).stringof~" (no infinity support)."); | ||
| assert (sig != 0, "Infinity floating point value assigned to a " |
There was a problem hiding this comment.
No space after assert. Same throughout
There was a problem hiding this comment.
Not in the style guide.
There was a problem hiding this comment.
Then add it: https://github.com/dlang/dlang.org/edit/master/dstyle.dd ;-)
There was a problem hiding this comment.
assert() is by fair the dominant style in Phobos, and matches function calls. Please change it. Thanks.
There was a problem hiding this comment.
and matches function calls
Which is why I am against it. But let's agree to disagree for now.
|
Technically this is a breaking change. I have no opinion on if this should be merged or not but this should get approval from many core team members before getting merged. |
4744a41 to
c460851
Compare
|
All of the changes were cases of irrecoverable errors. |
Current coverage is 88.68% (diff: 88.88%)@@ master #4688 diff @@
==========================================
Files 121 121
Lines 73850 73852 +2
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
+ Hits 65494 65497 +3
+ Misses 8356 8355 -1
Partials 0 0
|
That's not true. For example, the |
|
I would argue that any code that tries to calculate |
|
That might be a valid argument (or might not be, if the vectors come from untrusted input), but it irrelevant here either case. This is a breaking API change, and we need to treat it as such. |
|
AFAIR, there were other PRs that changed
I seriously doubt anyone is relying on being able to catch bare |
|
You might have a point in so far as the I'll leave this to others to decide. |
c460851 to
9a2fde8
Compare
|
LGTM Will wait for yet another one LGTM from core team before merge |
|
For what it is worth needing to catch exceptions in math code makes it slower and annoying to use. |
|
@wilzbach I will make a pass over the module and add |
|
These look more like asserts then enforces to me. |
|
@ZombineDev Please add a warning in the changelog about this change |
|
Alright, will do later today. |
9a2fde8 to
54652b3
Compare
And also use onOutOfMemoryError instead of allocating and throwing a new exception when malloc fails.
54652b3 to
d9abb10
Compare
|
I added a changelog entry. Let me know if there's anything else I need to do. |
|
Is there a way to see the rendered changelog on @CyberShadow's tester? |
No sadly not atm - see #4228 for details, for now you can only compile the file on its own with e.g. |
|
Ping @9il @DmitryOlshansky, is there anything else for me to do? |
|
Auto-merge toggled on |
|
Thanks, @9il! |
... in order to make the code more
@nogcandnothrowfriendly.And also use
onOutOfMemoryErrorinstead of allocating and throwing a newexception when
mallocfails.