Bug 5145 – Regression(2.050, 1.065) override error with forward ref of superclass

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
All
Creation time
2010-10-31T12:46:00Z
Last change time
2015-06-09T05:11:47Z
Keywords
patch, rejects-valid
Assigned to
nobody
Creator
fawzi

Comments

Comment #0 by fawzi — 2010-10-31T12:46:39Z
The following code fails with {{{ t.d(24): Error: variable t.B.sync.this override cannot be applied to variable t.d(25): Error: function t.B.sync.__require override only applies to class member functions }}} then class B is declared after class A {{{ module t; interface I1{ void bla(); } interface I2 { I1 sync (); } class A : B { final override I1 sync() in { assert( valid ); } body { return null; } } class B : I2 { override I1 sync() in { assert( valid ); } body { return null; } final bool valid() { return true; } } }}}
Comment #1 by clugdbug — 2010-11-01T01:01:43Z
Applies to both D1 and D2. This was caused by svn683, which fixed bug 3602 "ICE(tocsym.c) compiling a class, if its super class has preconditions" And the problem is that it's using the scope from the parent function, which isn't quite right: some of the attributes should be dropped. I don't know if anything other than STCoverride can cause problems. func.c, FuncDeclaration::mergeFrequire, line 1688. FuncDeclaration *fdv = (FuncDeclaration *)foverrides.data[i]; /* The semantic pass on the contracts of the overridden functions must * be completed before code generation occurs (bug 3602). */ if (fdv->fdrequire && fdv->fdrequire->semanticRun != PASSsemantic3done) { assert(fdv->scope); + StorageClass oldstc = fdv->scope->stc; + fdv->scope->stc &= ~ STCoverride; fdv->semantic3(fdv->scope); + fdv->scope->stc = fdv->scope->stc; } sf = fdv->mergeFrequire(sf); if (fdv->fdrequire)
Comment #2 by clugdbug — 2010-11-01T01:51:34Z
This seems very similar to bug 5110, which is more general. Need to check if the patch for 5110 fixes this bug as well.
Comment #3 by clugdbug — 2010-11-22T07:01:01Z
*** Issue 5253 has been marked as a duplicate of this issue. ***
Comment #4 by bugzilla — 2010-12-05T12:58:27Z
(In reply to comment #2) > This seems very similar to bug 5110, which is more general. Need to check if > the patch for 5110 fixes this bug as well. Nope, different problem.
Comment #5 by bugzilla — 2010-12-05T16:31:14Z