[Issue 14035] string concatenation accepts ints in templates
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Sat Mar 21 23:24:00 PDT 2015
https://issues.dlang.org/show_bug.cgi?id=14035
--- Comment #14 from Kenji Hara <k.hara.pg at gmail.com> ---
(In reply to yebblies from comment #12)
> This is sort of the whole point of VRP
I think it's a problem in the current implemented semantics of VRP. Applying
VRP beyond the "type categories" will introduce human unfriendly behavior.
> The implicit conversion from int (etc) to char is useful and intentional.
It's useful only when it does not break user intentional. Otherwise it would be
harmful.
> Even if you wanted to make 'explicitly' typed
> declarations differently, these would have to be treated the same:
>
> enum c = 'a' + 1; // no explicit type, but will be inferred as int
> enum int d = 'a' + 1; // explicitly typed as int
> enum x = "xxx" ~ c ~ d;
I think above code should be error. If user want to make a character by the
expression 'a' + 1, c and d should be declared with char type.
And it will be consistent with runtime code behavior.
auto c = 'a' + 1;
int d = 'a' + 1;
auto x = "xxx" ~ c ~ d; // Error: incompatible types: 'string' and 'int'
--
More information about the Digitalmars-d-bugs
mailing list