[Issue 2464] Correct error message causes incorrect error messages
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Nov 20 18:04:12 PST 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2464
------- Comment #4 from jminer2613 at students.pcci.edu 2008-11-20 20:04 -------
re: #2 and #3: Good points, but this issue seems different to me. I understand
why the compiler reports extra errors on code that uses a previously undefined
variable:
char[] str = "Hello";
char[] func() { return strr; }
-----
errors.d(2): Error: undefined identifier strr
errors.d(2): Error: cannot implicitly convert expression (strr) of type int to
char[]
Currently, the compiler uses int for the undefined variable and reports an
extra error. This could be fixed as was mentioned (and I'd like that), but is
more understandable.
But I think this issue is separate. The example code I showed has an unrelated
delegate that does not use an undefined variable. The following is a similar
test case. Why would referencing an undefined variable in func() cause the
comipler to think the delegate in func2() returns an int?
void func() {
char[] j = "hi";
k = "there";
}
void delegate() foo;
void func2() {
foo = () {
};
}
-----
errors.d(3): Error: undefined identifier k
errors.d(3): Error: cannot implicitly convert expression ("there") of type
char[5u] to int
errors.d(8): Error: cannot implicitly convert expression (__dgliteral1) of type
int delegate() to void delegate()
--
More information about the Digitalmars-d-bugs
mailing list