Bug 17818 – Deprecation: std.container.array.RangeT(A) is not visiable

Status
RESOLVED
Resolution
FIXED
Severity
blocker
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2017-09-09T18:24:10Z
Last change time
2017-09-11T16:53:03Z
Assigned to
No Owner
Creator
Vino

Comments

Comment #0 by vino.bheeman — 2017-09-09T18:24:10Z
Hi, A function of type "Tuple!(RangeT!(Array!string), RangeT!(Array!ulong)) coSizeDirList" is throwing deprecation warning, this is critical function of our main function (finding size of sub folders) of 5 file system each with 10 -20 TB, this is the first test that we are using D and testing D functionality for our feature development on cloud computing on a very large server farm. , and we have designed using threads and parallelism for compute speed. Size.d(10): Deprecation: std.container.array.RangeT(A) is not visible from module Size Program Tuple!(RangeT!(Array!string), RangeT!(Array!ulong)) coSizeDirList () { string FFs = "C:\\Temp\\sapnas2\\BACKUP"; int SizeDir = 1; ulong subdirTotal; ulong subdirTotalGB; Array!(string) Subdir; Array!(ulong) Subsize; Tuple!((Array!string), (Array!string)) Result; auto dFiles = Array!string ((dirEntries(FFs, SpanMode.shallow).filter!(a => a.isDir))[].map!(a => a.name)); foreach (d; dFiles[]) { auto SdFiles = Array!ulong(dirEntries(d, SpanMode.depth).map!(a => a.size)); foreach(f; SdFiles[]) { subdirTotal += f; } subdirTotalGB = (subdirTotal/1024/1024); { Subdir ~= d; Subsize ~= subdirTotalGB; } if (subdirTotalGB > SizeDir) subdirTotal = 0; } return tuple (Subdir[], Subsize[]); } void main () { writeln(coSizeDirList[]); }
Comment #1 by issues.dlang — 2017-09-10T03:37:34Z
As was pointed out in the forum, this is not a bug: http://forum.dlang.org/thread/[email protected]#post-ooui7v:241er1:241:40digitalmars.com Rather, it's the result of a compiler bug being fixed. std.container.array,RangeT is private, and it's not supposed to be possible to refer to it by name any more than it's possible to refer to the result of almost any range-based function by name (though most of them use Voldemort types, whereas std.container.array is just making the type private). The buggy behavior that made it possoble has been deprecated - hence the deprecation message - and you need to update your code so that it does not refer to RangeT by name. In general, code should be using auto for the type of range variables, and when the type name is actually needed (e.g. for a member variable declaration), then using typeof on the expression that results in the range will give you the type (and if you need refer to it multiple times in ways that won't work with auto, then you can always alias the result of typeof to then have an explicit type name to use).
Comment #2 by vino.bheeman — 2017-09-10T15:36:39Z
Hi Jonathan. Thank you very much, as stated by you I used the auto function and now i am able to get the output without any warnings, but this do not help me in my overall program, meaning, when I call this sub function from the main thread function program it is not working as expected and throwing an error. Sub Function: auto coSizeDirList (string FFs, int SizeDir) { ulong subdirTotal; ulong subdirTotalGB; Array!string Subdir; Array!ulong Subsize; //Tuple!((Array!string), (Array!string)) Result; auto dFiles = Array!string ((dirEntries(FFs, SpanMode.shallow).filter!(a => a.isDir))[].map!(a => a.name)); foreach (d; dFiles[]) { auto SdFiles = Array!ulong(dirEntries(d, SpanMode.depth).map!(a => a.size)); foreach(f; SdFiles[]) { subdirTotal += f; } subdirTotalGB = (subdirTotal/1024/1024); { Subdir ~= d; Subsize ~= subdirTotalGB; } if (subdirTotalGB > SizeDir) subdirTotal = 0; } return tuple (Subdir[], Subsize[]); } Main Thread function : void ptSizeDirList (string[] SizeDirlst, int SizeDir) { try { //Array!string MStext; string[][] MStext; // Getting Error on this line, while trying to change it to auto; auto MSresult = taskPool.workerLocalStorage(MStext); logF.writeln("Function \t : List the Folder whose Size greater then ", SizeDir, " GB"); logF.writeln("Dir. Scanned \t :", SizeDirlst); logF.writeln("************************************************************************************"); logF.writefln("%-63s %.20s", "File Name", "Size (GB)"); logF.writeln("************************************************************************************"); foreach (string Fs; parallel(SizeDirlst[0 .. $], 1)) { auto FFs = Fs.strip; auto MSizeDirList = task(&coSizeDirList, FFs, SizeDir); MSizeDirList.executeInNewThread(); auto MSizeDirListData = MSizeDirList.workForce; MSresult.get ~= MSizeDirListData; } foreach(i; MSresult.toRange) if (!i.empty) { writefln("%(%-(%-63s %)\n%)", i[].sort!((a,b) => a[0] < b[0]).uniq); } writeln("************************************************************************************"); } catch (Exception e) { writeln(e.msg); } } void main () { string SizeDirlst = "C:\\Temp\\sapnas2\\BACKUP"; int SizeDir = 1; ptSizeDirList(SizeDirlst, SizeDir); } Error: Error: no identifier for declarator MStext Deprecation: use { } for an empty statement, not ; So what should i use to the line " string[][] MStext" in my main function and also, I have another program which return the range and passes the range as a function argument to another function which throws the same deprecation warning. Eg : auto function1 () { return tuple(data) // range array } void funciton2(RangeT!(Array!string) data2) { string data3 = "Test1"; string data4 = data3 ~ data2; writeln(data4); } void main () { string data2 = function1[]; funciton2(data2); } } Deprecation message at line auto funciton2(RangeT!(Array!string) data2). From, Vino.B
Comment #3 by vino.bheeman — 2017-09-11T16:53:03Z
The issue has been resolved.