www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20133] New: [REG2.084.0] Bogus slice assignment in recursive

https://issues.dlang.org/show_bug.cgi?id=20133

          Issue ID: 20133
           Summary: [REG2.084.0] Bogus slice assignment in recursive CTFE
                    call
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: regression
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: sludwig outerproduct.org

The following snippet yields "Error: array length mismatch assigning `[0..1]`
to `[1..3]`", although no slice assignment should be going on:

---
void bar(ref string text)
{
        text = text[1 .. $];
        string tcopy = text;
        if (tcopy.length > 0)
                bar(tcopy);
}

enum test = {
        string input = "foo";
        bar(input);
        return input;
} ();
---

Works as expected up to DMD 2.083.1.

--
Aug 15 2019