Thread overview
Effectless ExpressionStatement not caught at all
Aug 23, 2005
Stewart Gordon
Aug 28, 2005
Thomas Kühne
Aug 28, 2005
Stewart Gordon
Aug 29, 2005
Thomas Kühne
Aug 29, 2005
Stewart Gordon
Aug 30, 2005
Thomas Kühne
Aug 30, 2005
Thomas Kühne
Aug 30, 2005
Stewart Gordon
August 23, 2005
Using DMD 0.128, Windows 98SE.

The compiler passes this without error:

----------
void main() {
    int x;
    int[] y;

    5;
    10 - 7;
    x;
    x + x;
    x * 5;
    y.length;
    y[1];
    y.sizeof / x;
    "Hello, world!";
}
----------

http://www.digitalmars.com/d/statement.html#expression

"Expressions that have no effect, like (x + x), are illegal in expression statements."

Therefore, apart from the declarations at the top, there is not a single legal statement above.

Stewart.

-- 
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS/M d- s:- a->--- UB@ P+ L E@ W++@ N+++ o K- w++@ O? M V? PS- PE- Y? PGP- t- 5? X? R b DI? D G e++>++++ h-- r-- !y
------END GEEK CODE BLOCK------

My e-mail is valid but not my primary mailbox.  Please keep replies on the 'group where everyone may benefit.
August 28, 2005
Stewart Gordon schrieb:
> Using DMD 0.128, Windows 98SE.
> 
> The compiler passes this without error:
> 
> ----------
> void main() {
>     int x;
>     int[] y;
> 
>     5;
>     10 - 7;
>     x;
>     x + x;
>     x * 5;
>     y.length;
>     y[1];
>     y.sizeof / x;
>     "Hello, world!";
> }
> ----------
> 
> http://www.digitalmars.com/d/statement.html#expression
> 
> "Expressions that have no effect, like (x + x), are illegal in
> expression statements."
> 
> Therefore, apart from the declarations at the top, there is not a single legal statement above.

Added to DStress as http://dstress.kuehne.cn/nocompile/e/ExpressionStatement_03_A.d http://dstress.kuehne.cn/nocompile/e/ExpressionStatement_03_B.d http://dstress.kuehne.cn/nocompile/e/ExpressionStatement_03_C.d http://dstress.kuehne.cn/nocompile/e/ExpressionStatement_04_A.d http://dstress.kuehne.cn/nocompile/e/ExpressionStatement_04_B.d http://dstress.kuehne.cn/nocompile/e/ExpressionStatement_04_C.d http://dstress.kuehne.cn/nocompile/e/ExpressionStatement_05.d

Thomas
August 28, 2005
Q: Which of these testcases is the odd one out?  (Scroll down to find out)

In article <des1kj$b7a$1@digitaldaemon.com>, =?ISO-8859-1?Q?Thomas_K=FChne?= says...
>http://dstress.kuehne.cn/nocompile/e/ExpressionStatement_03_A.d http://dstress.kuehne.cn/nocompile/e/ExpressionStatement_03_B.d http://dstress.kuehne.cn/nocompile/e/ExpressionStatement_03_C.d http://dstress.kuehne.cn/nocompile/e/ExpressionStatement_04_A.d http://dstress.kuehne.cn/nocompile/e/ExpressionStatement_04_B.d http://dstress.kuehne.cn/nocompile/e/ExpressionStatement_04_C.d http://dstress.kuehne.cn/nocompile/e/ExpressionStatement_05.d








A: http://dstress.kuehne.cn/nocompile/e/ExpressionStatement_03_B.d

Because it doesn't test the same issue as the rest.  Rather, it parses as a
declaration (declare x to be a
pointer to an x).

Stewart.


August 29, 2005
Stewart Gordon schrieb:

> Q: Which of these testcases is the odd one out?  (Scroll down to find out)
> 
> In article <des1kj$b7a$1@digitaldaemon.com>, =?ISO-8859-1?Q?Thomas_K=FChne?= says...
> 
>>http://dstress.kuehne.cn/nocompile/e/ExpressionStatement_03_A.d http://dstress.kuehne.cn/nocompile/e/ExpressionStatement_03_B.d http://dstress.kuehne.cn/nocompile/e/ExpressionStatement_03_C.d http://dstress.kuehne.cn/nocompile/e/ExpressionStatement_04_A.d http://dstress.kuehne.cn/nocompile/e/ExpressionStatement_04_B.d http://dstress.kuehne.cn/nocompile/e/ExpressionStatement_04_C.d http://dstress.kuehne.cn/nocompile/e/ExpressionStatement_05.d
> 
[snip]
> 
> A: http://dstress.kuehne.cn/nocompile/e/ExpressionStatement_03_B.d
> 
> Because it doesn't test the same issue as the rest.  Rather, it parses as a
> declaration (declare x to be a
> pointer to an x).

A:
| void main(){
|	int x;
|	x;
| }

B:
| void main(){
|	int x;
|	x * x;
| }

C:
| void main(){
|	int x;
|	x * 5;
| }

I don't see any pointers.

Thomas

August 29, 2005
In article <deu8ef$238k$1@digitaldaemon.com>,
=?UTF-8?B?VGhvbWFzIEvDvGhuZQ==?= says...
<snip>
>> Because it doesn't test the same issue as the rest.  Rather, it parses as a declaration (declare x to be a pointer to an x).
<snip>
> B:
>> void main(){
>>     int x;
>>     x * x;
>> }
<snip>
> I don't see any pointers.

Welcome to D.  The type "pointer to x" is written as "x*".  And the simplest declaration has the form

Type Identifier;

so of course that's a declaration of a pointer.  And Walter told us once upon a time that if a Statement can parse as either DeclarationStatement or ExpressionStatement then it is treated as a DeclarationStatement.

What did you think "declare x to be a pointer to an x" looked like?

Stewart.


August 30, 2005
Stewart Gordon schrieb:
> In article <deu8ef$238k$1@digitaldaemon.com>,
> =?UTF-8?B?VGhvbWFzIEvDvGhuZQ==?= says...
> <snip>
> 
>>>Because it doesn't test the same issue as the rest.  Rather, it parses as a declaration (declare x to be a pointer to an x).
> 
> <snip>
> 
>>B:
>>
>>>void main(){
>>>    int x;
>>>    x * x;
>>>}
> 
> <snip>
> 
>>I don't see any pointers.
> 
> 
> Welcome to D.  The type "pointer to x" is written as "x*".  And the simplest declaration has the form
> 
> Type Identifier;
> 
> so of course that's a declaration of a pointer.  And Walter told us once upon a time that if a Statement can parse as either DeclarationStatement or ExpressionStatement then it is treated as a DeclarationStatement.
> 
> What did you think "declare x to be a pointer to an x" looked like?

If the above is interpreted as an DeclarationStatement the following code should compile, shouldn't it?

void main(){
	int x;
	x * y; // line 3
}

a.d(3): x is used as a type

Thomas
August 30, 2005
Thomas Kühne schrieb:
> Stewart Gordon schrieb:
> 
>>In article <deu8ef$238k$1@digitaldaemon.com>,
>>=?UTF-8?B?VGhvbWFzIEvDvGhuZQ==?= says...
>><snip>
>>
>>>>Because it doesn't test the same issue as the rest.  Rather, it parses as a declaration (declare x to be a pointer to an x).
>>
>><snip>
>>
>>>B:
>>>
>>>
>>>>void main(){
>>>>   int x;
>>>>   x * x;
>>>>}
>>
>><snip>
>>
>>>I don't see any pointers.
>>
>>
>>Welcome to D.  The type "pointer to x" is written as "x*".  And the simplest declaration has the form
>>
>>Type Identifier;
>>
>>so of course that's a declaration of a pointer.  And Walter told us once upon a time that if a Statement can parse as either DeclarationStatement or ExpressionStatement then it is treated as a DeclarationStatement.
>>
>>What did you think "declare x to be a pointer to an x" looked like?
> 
> 
> If the above is interpreted as an DeclarationStatement the following code should compile, shouldn't it?
> 
> void main(){
> 	int x;
> 	x * y; // line 3
> }
> 
> a.d(3): x is used as a type

Oh I see, my modified frontend is behaving differently than the offical one.

Thomas

August 30, 2005
In article <df0qa7$1602$1@digitaldaemon.com>, =?UTF-8?B?VGhvbWFzIEvDvGhuZQ==?=
says...
<snip>
>If the above is interpreted as an DeclarationStatement the following code should compile, shouldn't it?

It doesn't, because x isn't a type.

OTOH this will compile:

void main() {
alias int x;
x * y;
}

or

class x {
int z;
}

void main() {
x * y;
}

Stewart.