www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - error line number off by 1? Or not?

reply jicman <jicman_member pathlink.com> writes:
Greetings!

Please admire this piece of code.

char[] t = "";
blah
char[] o = "";

if I try to compile this code I get that there is an error on line 3. ie.

jic 15:06:28-> build test00.d 
test00.d(3): no identifier for declarator blah
test00.d(3): semicolon expected, not 'char'

if I add a few empty lines to the code, ie.,

jic 15:11:41-> cat test00.d
char[] t = "";
blah




char[] o = "";

and I try to compile that code, I get,

jic 15:11:37-> build test00.d 
test00.d(7): no identifier for declarator blah
test00.d(7): semicolon expected, not 'char'

which points to line 7.  Well, the problem is really on line 2, why does the
compiler points to line 7 when the problem is really on line 2?  Or, even worse,

jic 15:24:19-> cat test00.d
char[] t = "";
blah

/*
some
comments
here..






*/
char[] o = "";

here is the compiler's output:
jic 15:24:14-> build test00.d 
test00.d(15): no identifier for declarator blah
test00.d(15): semicolon expected, not 'char'

Just trying to understand, or is it a bug?  Also, in this last case, the error
should have been caught at line 4.

Any ideas?

thanks,

josé
Jun 17 2005
parent reply Thomas Kuehne <thomas-dloop kuehne.this-is-spam.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

jicman schrieb am Fri, 17 Jun 2005 19:27:40 +0000 (UTC):
 Greetings!

 Please admire this piece of code.

 char[] t = "";
 blah
 char[] o = "";

 if I try to compile this code I get that there is an error on line 3. ie.

 jic 15:06:28-> build test00.d 
 test00.d(3): no identifier for declarator blah
 test00.d(3): semicolon expected, not 'char'

 if I add a few empty lines to the code, ie.,

 jic 15:11:41-> cat test00.d
 char[] t = "";
 blah




 char[] o = "";

 and I try to compile that code, I get,

 jic 15:11:37-> build test00.d 
 test00.d(7): no identifier for declarator blah
 test00.d(7): semicolon expected, not 'char'

 which points to line 7.  Well, the problem is really on line 2, why does the
 compiler points to line 7 when the problem is really on line 2?  Or, even
worse,
<snip> The compiler is correct. Consider the following code: int a = 2; int /* A */ b /* B */ /* C */ /* D */ int c; /* E */ As you can see the error is at the start of line E and not at the end of A or B. Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFCsyp13w+/yD4P9tIRAunoAJ9O/rXgQ8k0cQ1WvQ1nMW3Fe6hpjQCgnOGp YcXJXJSJ9SAfjWgT9imfLvE= =wbtY -----END PGP SIGNATURE-----
Jun 17 2005
parent jicman <jicman_member pathlink.com> writes:
Thank you.

jic


Thomas Kuehne says...
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

jicman schrieb am Fri, 17 Jun 2005 19:27:40 +0000 (UTC):
 Greetings!

 Please admire this piece of code.

 char[] t = "";
 blah
 char[] o = "";

 if I try to compile this code I get that there is an error on line 3. ie.

 jic 15:06:28-> build test00.d 
 test00.d(3): no identifier for declarator blah
 test00.d(3): semicolon expected, not 'char'

 if I add a few empty lines to the code, ie.,

 jic 15:11:41-> cat test00.d
 char[] t = "";
 blah




 char[] o = "";

 and I try to compile that code, I get,

 jic 15:11:37-> build test00.d 
 test00.d(7): no identifier for declarator blah
 test00.d(7): semicolon expected, not 'char'

 which points to line 7.  Well, the problem is really on line 2, why does the
 compiler points to line 7 when the problem is really on line 2?  Or, even
worse,
<snip> The compiler is correct. Consider the following code: int a = 2; int /* A */ b /* B */ /* C */ /* D */ int c; /* E */ As you can see the error is at the start of line E and not at the end of A or B. Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFCsyp13w+/yD4P9tIRAunoAJ9O/rXgQ8k0cQ1WvQ1nMW3Fe6hpjQCgnOGp YcXJXJSJ9SAfjWgT9imfLvE= =wbtY -----END PGP SIGNATURE-----
Jun 17 2005