[Issue 24143] New: Chain unreachable code
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Sep 12 16:14:57 UTC 2023
https://issues.dlang.org/show_bug.cgi?id=24143
Issue ID: 24143
Summary: Chain unreachable code
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: regression
Priority: P1
Component: phobos
Assignee: nobody at puremagic.com
Reporter: james.gray at remss.net
Compiled with -w the code:
import std;
void main() {
auto x = only(1).chain(repeat(2));
}
gives the following errors:
/dlang/dmd/linux/bin64/../../src/phobos/std/range/package.d(1010): Warning:
statement is not reachable
/dlang/dmd/linux/bin64/../../src/phobos/std/range/package.d(1011): Warning:
statement is not reachable
Error: warnings are treated as errors
Use -wi if you wish to treat warnings only as informational.
So does the following where I have isolated chain:
import std.range : chain;
struct RepeatOne {
enum empty = false;
const front = 1;
const back = 1;
void popFront() {}
void popBack() {}
auto save() { return RepeatOne.init; }
}
struct OnlyOne {
bool empty = true;
auto front = 1;
auto back = 1;
void popFront() { empty=false; }
void popBack() { empty=false; }
auto save() { return typeof(this)(this.tupleof); }
}
void main() {
auto x = OnlyOne.init.chain(RepeatOne.init);
}
--
More information about the Digitalmars-d-bugs
mailing list