On Saturday, 7 October 2023 at 00:00:48 UTC, claptrap wrote:

char[] foo;
foo.length = 4;
foo[] = 'a'; // ok sets all elements
foo[] = "a"; // range error at runtime?
foo[] = "ab"; // range error at runtime?

So I meant to init with a char literal but accidently used double quotes. Should that even compile? Shouldn't the compiler at least complain when trying to init with "ab"?

Even though you now have gotten answers, I still agree with you that there should be some kind of "warning" or suggestion like, did you mean to assign incompatible types?

It could just check the element type and see if it matches the rhs type.

Reply via email to