D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 7518 - std.array.empty doesn't work for shared arrays
Summary: std.array.empty doesn't work for shared arrays
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: All All
: P2 regression
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-02-16 07:12 UTC by Robert Clipsham
Modified: 2012-02-28 18:20 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Robert Clipsham 2012-02-16 07:12:45 UTC
The following code:
----
import std.parallelism;
shared string[] options;
void main()
{
    foreach(option; parallel(options)) {
    }
}
----
Worked with dmd 2.057 but fails with dmd 2.058, with the errors:
----
/Users/robert/.dvm/compilers/dmd-2.058/bin/../src/phobos/std/parallelism.d(3858): Error: template std.array.empty(T) does not match any function template declaration
/Users/robert/.dvm/compilers/dmd-2.058/bin/../src/phobos/std/parallelism.d(3858): Error: template std.array.empty(T) cannot deduce template function from argument types !()(shared(immutable(char)[][]))
----
Tested on OS X and Linux.
Comment 1 David Simcha 2012-02-16 07:18:28 UTC
The root cause has nothing to do with std.parallelism.  empty() should work for shared arrays.

import std.array;

void main() {
    shared string[] stuff;
    stuff.empty;
}

test.d(5): Error: template std.array.empty(T) does not match any function template declaration
test.d(5): Error: template std.array.empty(T) cannot deduce template function from argument types !()(shared(immutable(char)[][]))
Comment 2 Walter Bright 2012-02-27 19:21:47 UTC
This reduces to:

bool empty(T)(in T[] a)
{
    return !a.length;
}


void main() {
    shared string[] stuff;
    stuff.empty();
}
Comment 3 github-bugzilla 2012-02-28 18:20:37 UTC
Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/224fb68cb3fc16f5ad0e2caaae3ad0623c06b04c
fix Issue 7518 - std.array.empty doesn't work for shared arrays