[Issue 14682] [REG2.037] Incorrect interpretation of ~ []

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Thu Jun 11 17:27:30 PDT 2015


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

--- Comment #11 from Steven Schveighoffer <schveiguy at yahoo.com> ---
(In reply to Vladimir Panteleev from comment #10) 
> Yes. This is not where the problem lies. The problem is not with the ternary
> statement, but with the ~[] after it. And yes, this is one possible but
> inconvenient syntax to replace [].

OOOHHHH! oops :)

Hm... looking at that, well, I don't see a huge problem, just remove the
trailing []. But then again, you could be doing something generative.

In either case, I agree that the the syntax is ambiguous. I don't know what
should be done, quite possibly the only viable thing is to error on [], and
make you specify the type you are trying to do. Otherwise, you'd silently
change the meaning of the code. That sucks. I would expect probably the answer
is to leave it the way it is, and require the workaround.

For strings, it's pretty annoying, because nobody ever creates string literals
via [], but for something like int[][], it's not so cut and dry.

--


More information about the Digitalmars-d-bugs mailing list