[Issue 12616] AssertError in std.utf.decode

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Wed Apr 23 12:21:10 PDT 2014


https://issues.dlang.org/show_bug.cgi?id=12616

--- Comment #2 from monarchdodra at gmail.com ---
(In reply to Andrej Mitrovic from comment #1)
> Interesting problem. I think decode is wrong in using asserts here. asserts
> are for checking program state, enforce is for checking input. So I think
> the assert should be changed to:
> 
> enforceEx!UTFException(isValidDchar(result));
> 
> Or something similar. monarchdodra what do you think?

I think decode is supposed to throw an exception when it does decode an invalid
character (and usually does).

The assert is thrown in a "out" contract. If it triggers, it means decode has
failed to detect the bad character. The assert itself shouldn't actually be
changed, it just means there's an internal bug.

Now, we need to figure out which character is being thrown, and how it "passed
through the decode net". Interesting problem. I'll investigate.

--


More information about the Digitalmars-d-bugs mailing list