digitalmars.D.bugs - version'd else-if
- derick_eddington nospam.yashmoo.com (20/20) Jun 01 2005 DMD 0.125 on Linux.
- Derek Parnell (21/44) Jun 01 2005 The docs say that the body of a version block must be valid D statements...
- Jarrett Billingsley (5/18) Jun 02 2005 Might have to have an extra set of {} after the version statement - or e...
- derick_eddington nospam.yashmoo.com (11/43) Jun 02 2005 I wondered about that too at first but it's not at all just textually in...
- zwang (22/47) Jun 01 2005 This is not a bug.
DMD 0.125 on Linux.
: import std.stdio;
:
: void main (char[][] args)
: {
: if (args.length = 2) {
: writefln("2");
: }
: version (BUG) {
: else if (args.length == 3) {
: writefln("3");
: }
: }
: }
$ dmd verelif.d
verelif.d(9): found 'else' instead of statement
verelif.d(13): unrecognized declaration
$ dmd -version=BUG verelif.d
verelif.d(9): found 'else' instead of statement
verelif.d(13): unrecognized declaration
Jun 01 2005
On Wed, 1 Jun 2005 07:56:16 +0000 (UTC),
derick_eddington nospam.yashmoo.com wrote:
DMD 0.125 on Linux.
: import std.stdio;
:
: void main (char[][] args)
: {
: if (args.length = 2) {
: writefln("2");
: }
: version (BUG) {
: else if (args.length == 3) {
: writefln("3");
: }
: }
: }
$ dmd verelif.d
verelif.d(9): found 'else' instead of statement
verelif.d(13): unrecognized declaration
$ dmd -version=BUG verelif.d
verelif.d(9): found 'else' instead of statement
verelif.d(13): unrecognized declaration
The docs say that the body of a version block must be valid D statements,
and 'else' never starts a valid D statement. So its not a bug.
Try rearranging it thus ...
void main (char[][] args)
{
if (args.length == 2) {
writefln("2");
}
else
version (BUG) {
if (args.length == 3) {
writefln("3");
}
}
}
--
Derek
Melbourne, Australia
1/06/2005 6:39:25 PM
Jun 01 2005
"Derek Parnell" <derek psych.ward> wrote in message
news:g6j77wymnkft.9f9aw0m8symi$.dlg 40tude.net...
Try rearranging it thus ...
void main (char[][] args)
{
if (args.length == 2) {
writefln("2");
}
else
version (BUG) {
if (args.length == 3) {
writefln("3");
}
}
}
Might have to have an extra set of {} after the version statement - or else
anything after the version statement, if BUG is not defined, will be the
"else" statement!
Jun 02 2005
In article <d7npko$27fp$1 digitaldaemon.com>, Jarrett Billingsley says..."Derek Parnell" <derek psych.ward> wrote in message news:g6j77wymnkft.9f9aw0m8symi$.dlg 40tude.net...I wondered about that too at first but it's not at all just textually including like I was assuming before. version() is ConditionalStatement which is a Statement, and in this case it is always seen as the Statement of the 'else'. For example:Try rearranging it thus ... void main (char[][] args) { if (args.length == 2) { writefln("2"); } else version (BUG) { if (args.length == 3) { writefln("3"); } } }Might have to have an extra set of {} after the version statement - or else anything after the version statement, if BUG is not defined, will be the "else" statement!$ ./verelif hmm $ ./verelif abc 2 hmmvoid main (char[][] args) { if (args.length == 2) { writefln("2"); } else version (BUG) { if (args.length == 3) { writefln("3"); } } writefln("hmm"); }
Jun 02 2005
derick_eddington nospam.yashmoo.com wrote:
DMD 0.125 on Linux.
: import std.stdio;
:
: void main (char[][] args)
: {
: if (args.length = 2) {
: writefln("2");
: }
: version (BUG) {
: else if (args.length == 3) {
: writefln("3");
: }
: }
: }
$ dmd verelif.d
verelif.d(9): found 'else' instead of statement
verelif.d(13): unrecognized declaration
$ dmd -version=BUG verelif.d
verelif.d(9): found 'else' instead of statement
verelif.d(13): unrecognized declaration
This is not a bug.
Your sample code violates the syntax defined in
http://www.digitalmars.com/d/version.html
ConditionalDeclaration:
Condition DeclarationBlock
Condition DeclarationBlock else DeclarationBlock
DeclarationBlock:
Declaration
{ Declarations }
Declarations:
Declaration
Declaration Declarations
ConditionalStatement:
Condition Statement
Condition Statement else Statement
Condition:
VersionCondition
DebugCondition
StaticIfCondition
IfTypeCondition
Jun 01 2005









derick_eddington nospam.yashmoo.com 