From 97e936844677bedf0ab9a05739f63f843cddd155 Mon Sep 17 00:00:00 2001 From: k-hara Date: Mon, 7 Jan 2013 21:55:32 +0900 Subject: [PATCH 1/3] fix Issue 9268 - [ice-on-invalid] void assignment in fail44.d no longer caught in frontend --- src/expression.c | 4 ++-- test/fail_compilation/fail44.d | 13 ++++++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/expression.c b/src/expression.c index 31beec1e5bbe..15fb0e32d63c 100644 --- a/src/expression.c +++ b/src/expression.c @@ -10624,13 +10624,13 @@ Expression *AssignExp::semantic(Scope *sc) Type *t1 = e1->type->toBasetype(); e2 = e2->inferType(t1); - if (!e2->rvalue()) - return new ErrorExp(); e2 = e2->semantic(sc); if (e2->op == TOKerror) return new ErrorExp(); e2 = resolveProperties(sc, e2); + if (!e2->rvalue()) + return new ErrorExp(); /* Rewrite tuple assignment as a tuple of assignments. */ diff --git a/test/fail_compilation/fail44.d b/test/fail_compilation/fail44.d index 06220b71b57c..b8916a009912 100644 --- a/test/fail_compilation/fail44.d +++ b/test/fail_compilation/fail44.d @@ -1,12 +1,19 @@ +/* +TEST_OUTPUT: +--- +fail_compilation/fail44.d(18): Error: expression bar[i] is void and has no value +--- +*/ + void Foo() { void[] bar; void[] foo; - + bar.length = 50; foo.length = 50; - - for(int i=0; i<50; i++) + + for(size_t i=0; i<50; i++) { foo[i] = bar[i]; } From fb98b5fd728891fb147dd8c2e1e4f61c34a00e06 Mon Sep 17 00:00:00 2001 From: k-hara Date: Mon, 7 Jan 2013 23:15:58 +0900 Subject: [PATCH 2/3] Add "Internal error: ..." check --- test/d_do_test.d | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/d_do_test.d b/test/d_do_test.d index 33d1d1782ff1..95cabd0b2b03 100755 --- a/test/d_do_test.d +++ b/test/d_do_test.d @@ -417,10 +417,14 @@ int main(string[] args) } } + compile_output = std.string.strip(compile_output); + compile_output = compile_output.unifyNewLine(); + + auto m = std.regex.match(compile_output, `Internal error: .*$`); + enforce(!m, m.hit); + if (testArgs.compileOutput !is null) { - compile_output = std.string.strip(compile_output); - compile_output = compile_output.unifyNewLine(); compile_output = std.regex.replace(compile_output, regex(`DMD v2\.[0-9]+ DEBUG\n`, ""), ""); compile_output = std.regex.replace(compile_output, regex(`\nDMD v2\.[0-9]+ DEBUG`, ""), ""); enforce(compile_output == testArgs.compileOutput, From 5bcba1f0ff22786d47dacf7f24d9d9231291ef7c Mon Sep 17 00:00:00 2001 From: Andrej Mitrovic Date: Mon, 7 Jan 2013 18:22:57 +0100 Subject: [PATCH 3/3] Fixes Issue 9191 - Wrong diagnostic on failing override. For failing overrides the compiler should look for similar symbols in the base classes and interfaces, and not the current class. --- src/func.c | 10 ++++++-- test/fail_compilation/diag9191.d | 41 ++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 test/fail_compilation/diag9191.d diff --git a/src/func.c b/src/func.c index 7b9294ab0806..248fe5e3e79a 100644 --- a/src/func.c +++ b/src/func.c @@ -631,9 +631,15 @@ void FuncDeclaration::semantic(Scope *sc) if (!doesoverride && isOverride()) { - Dsymbol *s = cd->search_correct(ident); + Dsymbol *s = NULL; + for (size_t i = 0; i < cd->baseclasses->dim; i++) + { + s = (*cd->baseclasses)[i]->base->search_correct(ident); + if (s) break; + } + if (s) - error("does not override any function, did you mean '%s'", s->toPrettyChars()); + error("does not override any function, did you mean to override '%s'?", s->toPrettyChars()); else error("does not override any function"); } diff --git a/test/fail_compilation/diag9191.d b/test/fail_compilation/diag9191.d new file mode 100644 index 000000000000..0b2cf0dbbe8e --- /dev/null +++ b/test/fail_compilation/diag9191.d @@ -0,0 +1,41 @@ +/* +TEST_OUTPUT: +--- +fail_compilation/diag9191.d(16): Error: function diag9191.C1.aaa does not override any function, did you mean to override 'diag9191.B1.aa'? +fail_compilation/diag9191.d(21): Error: function diag9191.C2.aaa does not override any function, did you mean to override 'diag9191.I1.a'? +fail_compilation/diag9191.d(31): Error: function diag9191.C3.foo does not override any function, did you mean to override 'diag9191.B2._foo'? +fail_compilation/diag9191.d(36): Error: function diag9191.C4.toStringa does not override any function, did you mean to override 'object.Object.toString'? +--- +*/ + +interface I1 { void a(); } +class B1 { void aa(); } + +class C1 : B1, I1 +{ + override void aaa(); +} + +class C2 : I1 +{ + override void aaa(); +} + +class B2 +{ + void _foo(){} +} + +class C3 : B2 +{ + override void foo(){} +} + +class C4 +{ + override void toStringa(){} +} + +void main() +{ +}