[Issue 14035] string concatenation accepts ints in templates

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sat Mar 21 22:16:08 PDT 2015


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

--- Comment #7 from Ketmar Dark <ketmar at ketmar.no-ip.org> ---
the type IS changed. in no way compiler does runtime analysis to allow
converting `size_t` to `char`, it simply rejects such code. yet for
*explicitly* defined type in template compiler — for some unknown reason —
narrows the type. so we actually have THREE types here:
• "runtime `size_t`"
• "compile-time `size_t` which fits to char"
• "compile-time `size_t` which doesn't fit to char"
for another unknown reason they all called `size_t`, which is obviously wrong.

as for your sample with `'a'+1`: 'a' is *literal* here. as i told ealier, i can
accept type deduction for literals (it's wrong too in this case, but ok, let's
leave it as is). but i can't see why `size_t` has three definitions, and two of
that definitions *depends* *on* *instantiation* *line*. it's insane.

--


More information about the Digitalmars-d-bugs mailing list