Error: cannot return non-void from void function
    Graham Fawcett via Digitalmars-d-learn 
    digitalmars-d-learn at puremagic.com
       
    Thu Nov 27 05:48:53 PST 2014
    
    
  
On Thursday, 27 November 2014 at 13:07:59 UTC, Suliman wrote:
> Full function look like this:
>
> auto parseConfig()
> {
> 	auto config = Ini.Parse(getcwd ~ "\\" ~ "config.ini");
> 	string txtlinks = getcwd ~ "\\" ~ config.getKey("input_links");
> 	if(!exists(txtlinks))
> 	{
> 		writeln("Can't find input file with list of links.");
> 		return;
> 	}
> 	auto lines = File(txtlinks, "r").byLine;
> 	return lines;
>
> }
You have two return statements in your function. Each of them 
returns a result of a different type (the first one returns a 
"void" result). That's not allowed.
Instead of writing "Can't find input file" and then returning, 
consider throwing an exception. Then you only have one return 
statement, and one return type.
Graham
    
    
More information about the Digitalmars-d-learn
mailing list