Thread overview
Concat or add ~. Is this a bug?
Mar 21, 2005
jicman
Mar 21, 2005
Regan Heath
Mar 21, 2005
jicman
Mar 22, 2005
Regan Heath
Mar 22, 2005
Thomas Kuehne
March 21, 2005
Should this compile?  it should, at least, gives me warnings.

<code>
01. import std.stdio;
02. void TurnToMonDigit(char[] mon)
03. {
04.   char[] mm;
05.   mm = "I am trying to see if this also breaks" ~ mon ~ " more \n" ~
06.   "because this broke for me" ~
07.   "yep it did" ~
08.   "of course, new lines are needed\n";
09.   "new lines also\n";
10.   "this should not compile" ~
11.   " no it should not ";
12.   writefln(mm);
13.
14. }
15. void main (char[][] args)
16. {
17.   TurnToMonDigit("JUU");
18. }
</code>

Note line 08 and 09.  They have no variable assignment.  It's just an empty

"";
"";

but what causes me more trouble is what follows,

"..." ~
"..." ~
"..." ~
"...";

a concatenation to nothing.  Well, this was a bug in my program. :-)  So, I wasn't testing or anything. :-)

any ideas why this should compile?

thanks,

josé


March 21, 2005
On Mon, 21 Mar 2005 22:51:29 +0000 (UTC), jicman <jicman_member@pathlink.com> wrote:
> Should this compile?

No. IIRC a statement that is pointless or has no effect is an error. I can't, however, seem to find the part of the spec that says this, so I might be imagining it.

> <code>
> 01. import std.stdio;
> 02. void TurnToMonDigit(char[] mon)
> 03. {
> 04.   char[] mm;
> 05.   mm = "I am trying to see if this also breaks" ~ mon ~ " more \n" ~
> 06.   "because this broke for me" ~
> 07.   "yep it did" ~
> 08.   "of course, new lines are needed\n";
> 09.   "new lines also\n";
> 10.   "this should not compile" ~
> 11.   " no it should not ";
> 12.   writefln(mm);
> 13.
> 14. }
> 15. void main (char[][] args)
> 16. {
> 17.   TurnToMonDigit("JUU");
> 18. }
> </code>

Lines 8, 9, and 10 + 11 are pointless statements and should be errors.

> but what causes me more trouble is what follows,
>
> "..." ~
> "..." ~
> "..." ~
> "...";
>
> a concatenation to nothing.

That's another pointless statement and should be an error.

Regan
March 21, 2005
Well, it does...

Plus, I kept thinking that Windows has memory problems (which I know it does, but this was no way to prove it. :-))  I kept looking as to why I was missing half of my prints!  And couldn't understand why.  Then I reaaaaaaally looked at the code and saw the bug.  So... anyway, perhaps it should be fixed.

josé

Regan Heath says...
>
>On Mon, 21 Mar 2005 22:51:29 +0000 (UTC), jicman <jicman_member@pathlink.com> wrote:
>> Should this compile?
>
>No. IIRC a statement that is pointless or has no effect is an error. I can't, however, seem to find the part of the spec that says this, so I might be imagining it.
>
>> <code>
>> 01. import std.stdio;
>> 02. void TurnToMonDigit(char[] mon)
>> 03. {
>> 04.   char[] mm;
>> 05.   mm = "I am trying to see if this also breaks" ~ mon ~ " more \n" ~
>> 06.   "because this broke for me" ~
>> 07.   "yep it did" ~
>> 08.   "of course, new lines are needed\n";
>> 09.   "new lines also\n";
>> 10.   "this should not compile" ~
>> 11.   " no it should not ";
>> 12.   writefln(mm);
>> 13.
>> 14. }
>> 15. void main (char[][] args)
>> 16. {
>> 17.   TurnToMonDigit("JUU");
>> 18. }
>> </code>
>
>Lines 8, 9, and 10 + 11 are pointless statements and should be errors.
>
>> but what causes me more trouble is what follows,
>>
>> "..." ~
>> "..." ~
>> "..." ~
>> "...";
>>
>> a concatenation to nothing.
>
>That's another pointless statement and should be an error.
>
>Regan


March 22, 2005
On Mon, 21 Mar 2005 23:58:32 +0000 (UTC), jicman <jicman_member@pathlink.com> wrote:
> Well, it does...
>
> Plus, I kept thinking that Windows has memory problems (which I know it does,
> but this was no way to prove it. :-))  I kept looking as to why I was missing
> half of my prints!  And couldn't understand why.  Then I reaaaaaaally looked at
> the code and saw the bug.  So... anyway, perhaps it should be fixed.

Indeed. I'm cross-posting this to digitalmars.D.bugs so Walter will see it.

Regan

> josé
>
> Regan Heath says...
>>
>> On Mon, 21 Mar 2005 22:51:29 +0000 (UTC), jicman
>> <jicman_member@pathlink.com> wrote:
>>> Should this compile?
>>
>> No. IIRC a statement that is pointless or has no effect is an error. I
>> can't, however, seem to find the part of the spec that says this, so I
>> might be imagining it.
>>
>>> <code>
>>> 01. import std.stdio;
>>> 02. void TurnToMonDigit(char[] mon)
>>> 03. {
>>> 04.   char[] mm;
>>> 05.   mm = "I am trying to see if this also breaks" ~ mon ~ " more \n" ~
>>> 06.   "because this broke for me" ~
>>> 07.   "yep it did" ~
>>> 08.   "of course, new lines are needed\n";
>>> 09.   "new lines also\n";
>>> 10.   "this should not compile" ~
>>> 11.   " no it should not ";
>>> 12.   writefln(mm);
>>> 13.
>>> 14. }
>>> 15. void main (char[][] args)
>>> 16. {
>>> 17.   TurnToMonDigit("JUU");
>>> 18. }
>>> </code>
>>
>> Lines 8, 9, and 10 + 11 are pointless statements and should be errors.
>>
>>> but what causes me more trouble is what follows,
>>>
>>> "..." ~
>>> "..." ~
>>> "..." ~
>>> "...";
>>>
>>> a concatenation to nothing.
>>
>> That's another pointless statement and should be an error.
>>
>> Regan
>
>

March 22, 2005
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Regan Heath schrieb am Tue, 22 Mar 2005 12:15:25 +1200:
> On Mon, 21 Mar 2005 23:58:32 +0000 (UTC), jicman
><jicman_member@pathlink.com> wrote:
>>> No. IIRC a statement that is pointless or has no effect is an error. I can't, however, seem to find the part of the spec that says this, so I might be imagining it.
>>>
>>>> <code>
>>>> 01. import std.stdio;
>>>> 02. void TurnToMonDigit(char[] mon)
>>>> 03. {
>>>> 04.   char[] mm;
>>>> 05.   mm = "I am trying to see if this also breaks" ~ mon ~ " more \n"
>>>> ~
>>>> 06.   "because this broke for me" ~
>>>> 07.   "yep it did" ~
>>>> 08.   "of course, new lines are needed\n";
>>>> 09.   "new lines also\n";
>>>> 10.   "this should not compile" ~
>>>> 11.   " no it should not ";
>>>> 12.   writefln(mm);
>>>> 13.
>>>> 14. }
>>>> 15. void main (char[][] args)
>>>> 16. {
>>>> 17.   TurnToMonDigit("JUU");
>>>> 18. }
>>>> </code>

Added to DStress as http://dstress.kuehne.cn/nocompile/double_quoted_string_19.d http://dstress.kuehne.cn/nocompile/double_quoted_string_20.d

Thomas


-----BEGIN PGP SIGNATURE-----

iD8DBQFCP7503w+/yD4P9tIRAuP7AJ9Cw8BYee44RxR3LJ9VBKfTWb6BYQCfcK2m
FOIeQVHUtyCD2D2aYV2IaTs=
=eCiF
-----END PGP SIGNATURE-----