3679 – Regression(2.031) template forward reference regression

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 3679 - Regression(2.031) template forward reference regression
Summary: Regression(2.031) template forward reference regression
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: All All
: P2 regression
Assignee: No Owner
URL:
Keywords: rejects-valid
Depends on: 4503
Blocks:
Show dependency tree / graph
Reported: 2010年01月05日 20:25 UTC by Koroskin Denis
Modified: 2014年04月18日 09:12 UTC (History)
3 users (show)

See Also:


Attachments
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description Koroskin Denis 2010年01月05日 20:25:12 UTC
Test case:
module test;
public class Derived : public Base
{
}
class Template(T)
{
}
alias Template!(bool) TemplateAlias;
class Base
{
 TemplateAlias templateAlias;
}
# dmd test.d
test.d(13): Error: forward reference to 'Template!(bool)'
test.d(13): Error: TemplateAlias is used as a type
test.d(13): Error: variable test.Base.templateAlias voids have no value
Regression since DMD2.031, blocker for me to upgrate to a newer compiler version.
Comment 1 Don 2010年01月24日 23:58:37 UTC
This is also a D1 regression. It worked on 1.046, fails on 1.047 and later.
Comment 2 Don 2010年01月25日 02:07:38 UTC
The regression was caused by adding a couple of lines to ClassDeclaration::semantic(Scope *sc) in class.c in D1.047.
I think this was probably part of the fix for bug 3170.
Currently line 350 in the D1 source, commenting out the two lines marked '-' allows this test case to compile again. I think the bug lies elsewhere, however.
=========
		if (!tc->sym->symtab || tc->sym->scope || tc->sym->sizeok == 0)
		{
		 //printf("%s: forward reference of base class %s\n", toChars(), tc->sym->toChars());
		 //error("forward reference of base class %s", baseClass->toChars());
		 // Forward reference of base class, try again later
		 //printf("\ttry later, forward reference of base class %s\n", tc->sym->toChars());
		 scope = scx ? scx : new Scope(*sc);
		 scope->setNoFree();
-		 if (tc->sym->scope)
-		 tc->sym->scope->module->addDeferredSemantic(tc->sym);
		 scope->module->addDeferredSemantic(this);
		 return;
		}
Comment 3 Trass3r 2010年07月27日 10:15:04 UTC
The patch for http://d.puremagic.com/issues/show_bug.cgi?id=4503 also seems to fix this one.
Comment 4 Walter Bright 2010年08月08日 21:35:10 UTC
Fixed with 4503


AltStyle によって変換されたページ (->オリジナル) /