Bug 7518 – std.array.empty doesn't work for shared arrays

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-02-16T07:12:00Z
Last change time
2012-02-28T18:20:49Z
Assigned to
nobody
Creator
robert

Comments

Comment #0 by robert — 2012-02-16T07:12:45Z
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 by dsimcha — 2012-02-16T07:18:28Z
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 by bugzilla — 2012-02-27T19:21:47Z
This reduces to: bool empty(T)(in T[] a) { return !a.length; } void main() { shared string[] stuff; stuff.empty(); }
Comment #3 by github-bugzilla — 2012-02-28T18:20:37Z
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