www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - std.array.split - Template instantiating error

reply "nrgyzer" <nrgyzer gmail.com> writes:
Hi,

I've the following source:

import std.array : split;
import std.stdio : writeln;

void main()
{
    string myString = "Hello World";
    string[] splitted = myString.split(" ");
}

But when I compile the code above, I'm getting the following 
error:

Error: template instance std.array.split!(string, string) error 
instantiating.

I'm using the latest version of dmd (2.067.0), but I cannot 
figure out what I'm doing wrong :(. How to solve the problem?

Thanks in advance!
Apr 18 2015
next sibling parent reply Rikki Cattermole <alphaglosined gmail.com> writes:
On 18/04/2015 8:08 p.m., nrgyzer wrote:
 Hi,

 I've the following source:

 import std.array : split;
 import std.stdio : writeln;

 void main()
 {
     string myString = "Hello World";
     string[] splitted = myString.split(" ");
 }

 But when I compile the code above, I'm getting the following error:

 Error: template instance std.array.split!(string, string) error
 instantiating.

 I'm using the latest version of dmd (2.067.0), but I cannot figure out
 what I'm doing wrong :(. How to solve the problem?

 Thanks in advance!
alias immutable(char)[] string; T[] split(T, U=typeof(T.init[0]))(T from, U sep) Aka try changing " " to ' '.
Apr 18 2015
parent reply "nrgyzer" <nrgyzer gmail.com> writes:
On Saturday, 18 April 2015 at 08:13:00 UTC, Rikki Cattermole 
wrote:
 On 18/04/2015 8:08 p.m., nrgyzer wrote:
 Hi,

 I've the following source:

 import std.array : split;
 import std.stdio : writeln;

 void main()
 {
    string myString = "Hello World";
    string[] splitted = myString.split(" ");
 }

 But when I compile the code above, I'm getting the following 
 error:

 Error: template instance std.array.split!(string, string) error
 instantiating.

 I'm using the latest version of dmd (2.067.0), but I cannot 
 figure out
 what I'm doing wrong :(. How to solve the problem?

 Thanks in advance!
alias immutable(char)[] string; T[] split(T, U=typeof(T.init[0]))(T from, U sep) Aka try changing " " to ' '.
I already tried to change the separator from string (" ") to char (' ') . I'm getting the same result: array.d(1510): Error not a property splitter(range, sep).array sample.d(6): Error template instance std.array.split!(string, char) error instantiating
Apr 18 2015
parent reply Steven Schveighoffer <schveiguy yahoo.com> writes:
On 4/18/15 4:18 AM, nrgyzer wrote:

 array.d(1510): Error not a property splitter(range, sep).array
 sample.d(6): Error template instance std.array.split!(string, char)
 error instantiating
Are you using -property switch? Looks like std.array does not obey property switch requirements. I confirm that compiling with -property fails, while compiling without -property works. We really need to fix this, and by fix, I mean fix -property so it allows calling 0-arg functions without parentheses that aren't marked with property. -Steve
Apr 18 2015
parent "nrgyzer" <nrgyzer gmail.com> writes:
On Saturday, 18 April 2015 at 13:00:59 UTC, Steven Schveighoffer 
wrote:
 On 4/18/15 4:18 AM, nrgyzer wrote:

 array.d(1510): Error not a property splitter(range, sep).array
 sample.d(6): Error template instance std.array.split!(string, 
 char)
 error instantiating
Are you using -property switch? Looks like std.array does not obey property switch requirements. I confirm that compiling with -property fails, while compiling without -property works. We really need to fix this, and by fix, I mean fix -property so it allows calling 0-arg functions without parentheses that aren't marked with property. -Steve
Yeeeeees... Removing the -property switch solved the problem, thanks :)
Apr 18 2015
prev sibling parent "biozic" <dransic gmail.com> writes:
On Saturday, 18 April 2015 at 08:08:41 UTC, nrgyzer wrote:
 Hi,

 I've the following source:

 import std.array : split;
 import std.stdio : writeln;

 void main()
 {
    string myString = "Hello World";
    string[] splitted = myString.split(" ");
 }

 But when I compile the code above, I'm getting the following 
 error:

 Error: template instance std.array.split!(string, string) error 
 instantiating.

 I'm using the latest version of dmd (2.067.0), but I cannot 
 figure out what I'm doing wrong :(. How to solve the problem?

 Thanks in advance!
Works for me with DMD 2.067.0 on OSX: ["Hello", "World"]
Apr 18 2015