[Issue 14035] string concatenation accepts ints in templates

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sat Mar 21 21:50:56 PDT 2015


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

--- Comment #4 from Ketmar Dark <ketmar at ketmar.no-ip.org> ---
ln type is known in both cases. `usize` is `size_t`, if it matters. yet somehow
two `ln`s has *different* types. i can see how `(T ln=__LINE__)` can be
converted to char, as compiler is free to choose any integral type for `T`, and
it can be `ubyte`, if `__LINE__` is sufficiently small. but i specifically
wrote `usize`, and i can't see why compiler wants to narrow it in one case,
ignoring my explicit type definition, but doesn't want to narrow it in another
case.

from programmer's POV both samples should not work if type system is consistent
and works as expected. but type system is clearly not consistent, and to use it
successfully programmer must know corner cases and compiler internals.
something wrong either with language design or with type system here.

--


More information about the Digitalmars-d-bugs mailing list