www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21924] New: Internal compiler error with live

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

          Issue ID: 21924
           Summary: Internal compiler error with  live
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Windows
            Status: NEW
          Keywords: live
          Severity: minor
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: lempiji gmail.com

this code has internal compiler error with -preview=dip1021.

```
struct Handle
{
    private void* handle;

     disable this();
     disable this(this);

    this(int n)
    {
        handle = malloc(10);
    }

    void close()
    {
        free(handle);
    }
}

void main()
{
    scope h = Handle(10);
    h.close();
}
```


The reason is in `isBorrowedPtr`.

```
return v.isScope() && !v.isowner && v.type.nextOf().isMutable();
//v.type.nextOf() is null
```

`isReadonlyPtr` too:


```
return v.isScope() && !v.type.nextOf().isMutable(); // v.type.nextOf() is null
```

--
May 15