December 11, 2013 Re: std.utf: use throw UTFException instead of assert(0) in stride, etc | ||||
---|---|---|---|---|
| ||||
On Tuesday, December 10, 2013 15:52:06 Timothee Cour wrote:
> in std.utf shouldn't we throw UTFException instead of assert(0) in stride,
> etc ?
std.utf only uses assert(0) when that code should be unreachable. It's used to catch bugs in the implementation, not in a function's input. If anything in std.utf ever hits an assert(0), it's a bug. A UTFException _is_ thrown when a std.utf function encounters invalid Unicode. It's certainly possible that there's a bug involving assert(0) in std.utf, but there shouldn't be any case in all of Phobos where an assert(0) would actually be hit.
- Jonathan M Davis
|
December 11, 2013 Re: std.utf: use throw UTFException instead of assert(0) in stride, etc | ||||
---|---|---|---|---|
| ||||
Attachments:
| well then it's a bug: https://d.puremagic.com/issues/show_bug.cgi?id=11721 this is the 3rd regression I'm posting today! On Tue, Dec 10, 2013 at 4:45 PM, Jonathan M Davis <jmdavisProg@gmx.com>wrote: > On Tuesday, December 10, 2013 15:52:06 Timothee Cour wrote: > > in std.utf shouldn't we throw UTFException instead of assert(0) in > stride, > > etc ? > > std.utf only uses assert(0) when that code should be unreachable. It's > used to > catch bugs in the implementation, not in a function's input. If anything in > std.utf ever hits an assert(0), it's a bug. A UTFException _is_ thrown > when a > std.utf function encounters invalid Unicode. It's certainly possible that > there's a bug involving assert(0) in std.utf, but there shouldn't be any > case > in all of Phobos where an assert(0) would actually be hit. > > - Jonathan M Davis > |
Copyright © 1999-2021 by the D Language Foundation