dmd should not output error messages like these:
Error: function expected before (), not __error of type TOK149
I have never seen an error message that refers to __error, and that I wanted to see. They don't add any additional value, and are only (by definition?) caused by preceding, actual errors. They are only noise and don't add any additional value.
Comment #1 by clugdbug — 2010-06-16T08:50:34Z
(In reply to comment #0)
> dmd should not output error messages like these:
>
> Error: function expected before (), not __error of type TOK149
>
> I have never seen an error message that refers to __error, and that I wanted to
> see. They don't add any additional value, and are only (by definition?) caused
> by preceding, actual errors. They are only noise and don't add any additional
> value.
__error is a new improvement to the compiler to supress spurious error messages. (in previous releases, it would have been 'int'). You should never see them. Please post any test cases which produce them.
Comment #2 by nfxjfg — 2010-06-17T02:58:53Z
Don, it seems to happen all the time. Normally I fix my compilation error right away, so I don't have a test case ready. See bug 4335 for one.
Comment #3 by leandro.lucarella — 2010-06-17T06:40:46Z
Copied from bug 4335 for convenience:
---
import std.stdio;
void main() {
writeln("bug");
}
---
t.d(3): Error: 'writeln' is not defined, perhaps you need to import std.stdio;
?
t.d(3): Error: function expected before (), not __error of type _error_
(the first wrong error message is what bug 4335 is about)
Comment #4 by leandro.lucarella — 2010-06-17T06:41:48Z
BTW, note that this testcase is, unfortunately, D1 only.
Comment #5 by nfxjfg — 2010-06-17T07:15:10Z
It's possible that this is D1-only, I noticed the thing above only when working with D1 code.
Comment #6 by clugdbug — 2010-06-17T12:38:17Z
Come on, fellas, you can do better than that. Here's 3 examples, and the last one produces a segfault.
void bug4329()
{
with(great!().trepidation) return;
try{
throw CautionToTheWind;
} catch(LifeThreatening illness){}
}
Comment #7 by clugdbug — 2010-06-18T01:28:49Z
And here are another seven cases I found.
TEST CASE B:
--------------
void bug4329b()
{
create!().havoc!();
delete something;
mixin(chaos);
}
bug.d(25): Error: template instance template 'create' is not defined
bug.d(25): Error: undefined identifier create!().havoc
bug.d(25): Error: __error isn't a template
bug.d(26): Error: undefined identifier something
bug.d(26): Error: cannot delete type _error_
bug.d(27): Error: undefined identifier chaos
bug.d(27): Error: argument to mixin must be a string, not (__error)
bug.d(27): Error: argument to mixin must be a string, not (__error)
TEST CASE C:
--------------
void bug4329c()
{
delete and!(crash);
}
bug.d(33): Error: identifier 'crash' is not defined
bug.d(33): Error: and!(_error_) is not an lvalue
bug.d(33): Error: cannot delete type void
TEST CASE D:
--------------
void bug4329d() {
make!(mess);
switch(2) {
case 3:.. case 6.7:
case closed:
}
}
bug.d(37): Error: identifier 'mess' is not defined
bug.d(37): Error: make!(_error_) has no effect
bug.d(39): Error: cannot implicitly convert expression (6.7) of type double to i
nt
bug.d(39): Error: first case 3 is greater than last case __error
bug.d(40): Error: undefined identifier closed
bug.d(40): Error: case must be a string or an integral constant, not __error
Comment #8 by bearophile_hugs — 2010-07-03T11:03:58Z
This is a case I have found:
void main() {
int[] a = cast(int[])array(iota(10));
}
dmd 2.047 prints:
temp.d(2): Error: undefined identifier array
temp.d(2): Error: undefined identifier iota
Error: cannot cast _error_ to int[]
Comment #9 by bearophile_hugs — 2010-07-28T14:13:30Z
One case, dmd 2.047:
void main() {
auto x = foo.bar!();
}
test.d(2): Error: undefined identifier foo
test.d(2): Error: __error isn't a template
Comment #10 by bearophile_hugs — 2010-07-31T05:47:27Z
One case:
void main() {
enum Foo { E }
Foo f;
switch (f) {
case 1: break;
default: break;
}
}
dmd 2.047 prints:
test.d(5): Error: cannot implicitly convert expression (1) of type int to Foo
test.d(5): Error: case must be a string or an integral constant, not __error
Comment #11 by leandro.lucarella — 2010-08-13T20:07:43Z
Another testcase:
---
pragma (lib, l);
void main() {}
---
p.d(1): Error: undefined identifier l
p.d(1): Error: pragma lib string expected for library name, not '__error'
Comment #12 by bearophile_hugs — 2010-09-09T12:49:36Z
struct Foo {
int x;
}
void main() {
Foo(5 ^^ 5); // line 5
}
DMD 2.048 shows:
test.d(5): Error: must import std.math to use ^^ operator
test.d(5): Error: structliteral has no effect in expression (Foo((__error)))
---------------------------
void foo() {}
void main() {
foreach (x; foo()[0 .. 1]) {}
}
DMD 2.048 shows:
test.d(3): Error: foo() cannot be sliced with []
test.d(3): Error: foreach: _error_ is not an aggregate type
Comment #13 by bearophile_hugs — 2010-09-25T12:36:46Z
struct Vec(int N) {
int[N] data;
}
void main() {
Vec!(1)([1, 2]);
}
DMD 2.049 prints:
test.d(5): Error: cannot implicitly convert expression ([1,2]) of type int[] to int
test.d(5): Error: structliteral has no effect in expression (Vec((__error)))
Comment #14 by clugdbug — 2010-11-05T01:22:40Z
*** Issue 2464 has been marked as a duplicate of this issue. ***