www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 17112] New: Simple writeln call produces cryptic error message

https://issues.dlang.org/show_bug.cgi?id=17112

          Issue ID: 17112
           Summary: Simple writeln call produces cryptic error message
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Mac OS X
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: naclypi gmail.com

some working example code:
$ dmd --version
DMD64 D Compiler v2.072.2
Copyright (c) 1999-2016 by Digital Mars written by Walter Bright
$ dmd degenerate.d
Undefined symbols for architecture x86_64:
  "_D3std6format18__T10FormatSpecTaZ10FormatSpec6fillUpMFNaZv", referenced
from:
     
_D3std6format18__T10FormatSpecTaZ10FormatSpec63__T17writeUpToNextSpecTS3std5array17__T8AppenderTAyaZ8AppenderZ17writeUpToNextSpecMFNaS3std5array17__T8AppenderTAyaZ8AppenderZb
in degenerate.o
     
_D3std6format18__T10FormatSpecTaZ10FormatSpec59__T17writeUpToNextSpecTS3std5stdio4File17LockingTextWriterZ17writeUpToNextSpecMFS3std5stdio4File17LockingTextWriterZb
in degenerate.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Error: linker exited with status 1
-----------------<degenerate.d>------------------
import std.stdio;

void main(){
    writeln(["string1", "string2"]);
}

-------------------------------------------------
a more realistic example which causes the same error:
-----------------<realistic.d>-------------------
import std.stdio;     // for writeln
import std.algorithm; // for map
import std.conv;      // for to!string
import std.range;     // for iota

string[] substrings(string n) {
    // returns a "sliding window" array of substrings of n
    return iota(1,8).map!(i => n[i..(i+3)]).array;
}

void main(){
    int[] n = [0,1,2,3,4,5,6,7,8,9];
    writeln(n.map!(to!string).join.substrings); // <------------ this line
causes the error
    writeln(n.map!(to!string).join.substrings.join(",")); // <-- this would be
the fix
}
-------------------------------------------------
i think this is a regression because this error was not happening before i
updated dmd to v2.072.2.

--
Jan 21 2017