www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20730] New: [REG 2.091] Template instantiation errors after

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

          Issue ID: 20730
           Summary: [REG 2.091] Template instantiation errors after any
                    real errors
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: regression
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: ibuclaw gdcproject.org

Caused by: https://github.com/dlang/dmd/pull/10711

Test:
---
import xstd.stdio;

void test21()
{
    auto f = File().byLine;
}

void main()
{
    test23();
}
---

---
T atomicOp(string op, T, V1)(ref shared T val, V1 mod)
    if (__traits(compiles, mixin("*cast(T*)&val" ~ op ~ "mod")))
{
    return val;
}

struct File
{
    shared uint refs;

    this(this)
    {
        atomicOp!"+="(refs, 1);
    }

    struct ByLineImpl(Char)
    {
        File file;
        char[] line;
    }

    auto byLine()
    {
        return ByLineImpl!char();
    }
}
---


Expected output:
---
Error: undefined identifier `test23`, did you mean function `test21`?
---

Actual output:
---
Error: undefined identifier `test23`, did you mean function `test21`?
Error: template `stdio.atomicOp` cannot deduce function from argument types
`!("+=")(shared(uint), int)`, candidates are:
xstd/stdio.d(1):        `atomicOp(string op, T, V1)(ref shared T val, V1 mod)`
  with `op = "+=",
       T = uint,
       V1 = int`
  must satisfy the following constraint:
`       __traits(compiles, mixin("*cast(T*)&val" ~ op ~ "mod"))`
---

Fixing the first error makes the template instantiation error go away.

--
Apr 12