D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 14924 - Error in std.uri definition/description
Summary: Error in std.uri definition/description
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: x86_64 Linux
: P1 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-08-16 00:18 UTC by ted
Modified: 2020-03-21 03:56 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description ted 2015-08-16 00:18:35 UTC
dmd2.068.0

size_t defined as (from http://dlang.org/type.html): "size_t is an alias to one of the unsigned integral basic types"

(i.e. size_t is unsigned)

Both uriLength and emailLength return size_t.
...but are supposed to return -1 if invalid 

Cannot use a test that uses "< 0".

Additionaly, dmd does not issue any warning when performing this test.
Comment 1 basile-z 2015-08-16 01:04:57 UTC
https://github.com/D-Programming-Language/phobos/pull/3558

By the way, the ddoc for emailLength/uriLength would need to be revised a bit, wouldn't they ?
Comment 2 ted 2015-08-16 01:41:30 UTC
Another aspect that should be noted in the documentation is that only a _very_ narrow subset of URI's are accepted....

try ftp:///foo.com (valid URI, fails 'test').....!
Comment 3 basile-z 2015-08-16 02:26:05 UTC
It looks like std.uri hasn't changed since it's been added in 2007. If you look at the implementation it's really old fashioned D. 

For example nowadays, for `emailLength()` and `uriLength()`, the parameter would not be of type `in char[]` but at least `string` and even perahps an InputRange with a constraint of type  `if (isInputRange!T && isSomeChar!T)`...

I wouldn't be surprised if someone from the organisation would come and say that's it's deprecated and that instead a Regex can be used. I hang on Dlang only still one or two years so I can't say more...I may be wrong.