1 compiler error without error message

Jonathan Dunlap jadit2 at gmail.com
Fri May 10 18:18:42 PDT 2013


Building Solution: DFizzBuzz (Debug)



Building: DFizzBuzz (Debug)
Performing main compilation...

Current dictionary: C:\D\Projects\DFizzBuzz\DFizzBuzz
C:\D\dmd2\windows\bin\dmd.exe -debug -gc "main.d"  
"-IC:\D\dmd2\src\druntime\import" "-IC:\D\dmd2\src\phobos" 
"-odobj\Debug" 
"-ofC:\D\Projects\DFizzBuzz\DFizzBuzz\bin\Debug\DFizzBuzz.exe"

Exit code 1
Build complete -- 1 error, 0 warnings
---------------------- Done ----------------------
Build: 1 error, 0 warnings
===============================================

module main;

import std.stdio;
import std.file;
import std.path;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.typetuple;
import std.typecons;

// Sample input file:
// 3 5 10
// 2 7 15
void main(string[] args)
{
         string input;
	writeln("This program is the classic Fizz Buzz application.");
	writeln("It's more fun to let you play your own way.");
	input = chomp(readln());
	input = absolutePath(input);

	assert( input.isFile );
	auto lines = splitLines( readText(input) );
	foreach(line; lines) {
		writeln( getResults(line) );
	}
}

string getResults(string line)
{
	string[] members = std.regex.split(line, std.regex.regex(" "));
	int A = to!int(members[0]);
	int B = to!int(members[1]);
	int N = to!int(members[2]);

	string outputStr;

	alias Tuple!(int, bool, bool) RuleType;
//====== THE LINE THAT BREAKS THE COMPILER
	auto lazylist = map!(i => i, i => i % A==0, i => i % B==0)( 
iota(1, N+1, 1) );
// =====
	RuleType[] rules = array(lazylist);

	foreach(RuleType rule; rules) {
		if (rule[1]) outputStr ~= 'F';
		if (rule[2]) outputStr ~= 'B';
		else if (!rule[1]) outputStr ~= to!string(rule[0]);
		outputStr ~= " ";
	}
	return outputStr;
}


More information about the Digitalmars-d-learn mailing list