Bug 24143 – Chain unreachable code

Status
NEW
Severity
regression
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2023-09-12T16:14:57Z
Last change time
2024-12-01T16:41:47Z
Keywords
pull
Assigned to
No Owner
Creator
james.gray
Moved to GitHub: phobos#10531 →

Comments

Comment #0 by james.gray — 2023-09-12T16:14:57Z
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); }
Comment #1 by dlang-bot — 2023-09-12T17:29:39Z
@jamesragray created dlang/phobos pull request #8812 "chain unreachable code - Issue 24143" fixing this issue: - Added unittest for Issue 24143 - fix Issue 24143 https://github.com/dlang/phobos/pull/8812
Comment #2 by robert.schadek — 2024-12-01T16:41:47Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/phobos/issues/10531 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB