Implement error handling for (raw-)unicode-escape codec#694
Implement error handling for (raw-)unicode-escape codec#694slozier merged 3 commits intoIronLanguages:masterfrom
Conversation
| void handleError(int start, int end, string reason) { | ||
| bytesData ??= data is byte[] ba ? new Bytes(ba) : Bytes.Empty; | ||
|
|
||
| if (errorHandler == null || start >= bytesData.Count) { |
There was a problem hiding this comment.
If data is not byte[] it will ignore errorHandler and always throw (since bytesData.Count == 0). Is this the expected behavior? If we expect errorHandler to always be null with char[] then I would add a guard (Debug.Assert or NotImplementedException) at the top of the method.
There was a problem hiding this comment.
Yes, it was the intended behaviour. The current implementation assumes errorHandler to be always default with char[], since currently there is no need for a non-default handler in such case. If in the future this assumption is no longer valid, handleError has to be updated. I agree that a guard with NotImplementedException is better than a silent ignore.
slozier
left a comment
There was a problem hiding this comment.
Looks good to me! Thanks.
Similarities to
escape_decodeturned out to be smaller than I expected.