Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

std.range.indexed RangeError when indexing string with std.range.recurrence!"n"(0) #9998

Open
dlangBugzillaToGithub opened this issue Aug 7, 2013 · 1 comment

Comments

@dlangBugzillaToGithub
Copy link

monkeyworks12 reported this on 2013-08-07T13:51:29Z

Transfered from https://issues.dlang.org/show_bug.cgi?id=10774

Description

import std.stdio;
import std.range;

void main()
{
	auto str = "石室詩士施氏,嗜獅,誓食十獅。"d;
	auto indStr = str.indexed(recurrence!"n"(0));

        //core.exception.RangeError@std.range(6177): Range violation
	writeln(indStr);
}


This code prints the string correctly, but it seems that it doesn't stop when the end of the string is reached.

石室詩士施氏,嗜獅,誓食十獅。
@dlangBugzillaToGithub
Copy link
Author

monkeyworks12 commented on 2013-08-07T14:05:20Z

Also, a workaround:

import std.utf;
import std.stdio;
import std.range;

void main()
{
    auto str = "石室詩士施氏,嗜獅,誓食十獅。"d;
    auto indStr = str.indexed(iota(str.count));
    writeln(indStr);

    readln();
}

@LightBender LightBender removed the P3 label Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants