Thread overview
Unclear error message
Aug 11, 2004
Nick
Aug 11, 2004
J C Calvarese
Aug 15, 2004
Walter
August 11, 2004
Calling an undefined function gives a rather strange error message:

foo() gives

tst.d(3): undefined identifier foo
tst.d(3): function expected before (), not 'int'

There's no 'int' anywhere :)

Nick


August 11, 2004
Nick wrote:
> Calling an undefined function gives a rather strange error message:
> 
> foo() gives
> 
> tst.d(3): undefined identifier foo
> tst.d(3): function expected before (), not 'int'
> 
> There's no 'int' anywhere :)
> 
> Nick

It doesn't seem like much of a bug to me. The compiler is trying very hard to understand what you gave it. The first suggestion is produces absolutely right on the mark: "What's foo?" Once you define your function, the compiler doesn't assume it's an int anymore, does it?

The second line is the result of the compiler trying to be helpful, but the compiler can't read the mind of the user. It seems that the compiler assumes you meant to declare an int when it finds an undefined identifier. The second line isn't a very good guess in this case, but int is a common datatype, so could be helpful often.

Another case:

void main()
{
    foo[];
}

Output...
test.d(4): undefined identifier foo
test.d(4): int cannot be sliced with []

It seems to support my theory about the int assumption.


By the way, the code you specified gives this:
test.d(1): no identifier for declarator
test.d(1): semicolon expected, not 'EOF'


I suspect you were using code like this:

void main()
{
    foo();
}

test.d(4): undefined identifier foo
test.d(4): function expected before (), not 'int'


DMD used to only produce pretty much one error at a time, but I like this new capability to produce multiple errors.

-- 
Justin (a/k/a jcc7)
http://jcc_7.tripod.com/d/
August 15, 2004
The 'int' you're seeing is the result of the compiler, at the first error, trying to patch things up so it can proceed. It does this by just assuming one meant 'int' and then going forward.