www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21966] New: elem ~ elem could yield elem[]

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

          Issue ID: 21966
           Summary: elem ~ elem could yield elem[]
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: b2.temp gmx.com

idea hidden in DMD compiler

---
void main()
{
    char[] ab = 'a' ~ 'b';
    int[] z1 =  0 ~  1;
}    
---

CatExp of two compatible elems could result into a dynamic array, instead of
the current errors:

/tmp/temp_7F4CF56284B0.d:5:17: Error: incompatible types for `(cast(int)'a') ~
(cast(int)'b')`: both operands are of type `int`
/tmp/temp_7F4CF56284B0.d:6:17: Error: incompatible types for `(0) ~ (1)`: both
operands are of type `int`
--
May 25 2021