3723 – Regression: forward referenced enum

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 3723 - Regression: forward referenced enum
Summary: Regression: forward referenced enum
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: Other Windows
: P2 regression
Assignee: No Owner
URL:
Keywords: patch, rejects-valid
Depends on:
Blocks:
Reported: 2010年01月19日 08:44 UTC by Don
Modified: 2014年04月18日 09:12 UTC (History)
1 user (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 Don 2010年01月19日 08:44:58 UTC
This code worked on 1.053, fails to compile on 1.054, and on D2.
I suspect this was caused by the fix to bug 3611.
-----
FwdEnum this_fails;
enum :int
{
 E1 = 2
}
enum FwdEnum: int
{
 E2 = E1
}
-----
bug.d(10): Error: undefined identifier E1
Comment 1 Don 2010年01月19日 21:43:23 UTC
The regression is caused by this addition to Type *TypeEnum::toBasetype().
Knowing this doesn't necessarily help in fixing the problem, though.
Type *TypeEnum::toBasetype()
{
+ if (sym->scope)
+ {
+	sym->semantic(NULL);	// attempt to resolve forward reference
+ }
Comment 2 Don 2010年01月20日 11:31:37 UTC
I've fixed this by changing the code in mtype.c, line 5984:
Type *TypeEnum::toBasetype()
{
 if (sym->scope)
 {
- sym->semantic(NULL); // attempt to resolve forward reference
+ sym->trySemantic(NULL); // attempt to resolve forward reference
 }
and adding this code to enum.c:
void EnumDeclaration::trySemantic(Scope *sc)
{
 unsigned errors = global.errors;
 global.gag++;
 DsymbolTable *savetable = symtab;
 semantic(sc);
 global.gag--;
 if (errors != global.errors)
 { 
	global.errors = errors;
	symtab = savetable;
 }
}
Comment 3 Walter Bright 2010年01月24日 15:02:43 UTC
Changeset 353
Comment 4 Walter Bright 2010年01月30日 22:42:12 UTC
fixed dmd 1.056 and 2.040


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