www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22546] New: bad diagnostic for CTFE array cast of string in UDA

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

          Issue ID: 22546
           Summary: bad diagnostic for CTFE array cast of string in UDA
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: diagnostic
          Severity: minor
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: dkorpel live.nl

I was messing around with weird combinations of string literals and found this
oddity:
```
enum a = cast(dstring) "what"c;
 (cast(dstring) "huh"c) int x;
```

The first line gives:

Error: array cast from `string` to `dstring` is not supported at compile time

Makes sense, but the second line:

/dlang/dmd/linux/bin64/../../src/druntime/import/core/memory.d(1023): Error:
`fakePureErrno` cannot be interpreted at compile time, because it has no
available source code

When adding one more character to the string, it gets a bit more sensible
again:

/dlang/dmd/linux/bin64/../../src/druntime/import/core/internal/array/casting.d(90):
Error: reinterpreting cast from `string` to `Array*` is not supported in CTFE
onlineapp.d(2):        called from here: `__ArrayCast("huha"c)`

Not encountered in any actual code, so filing as a minor issue.

--
Nov 25 2021