D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 3261 - compiler crash with mixin and forward reference (Issue 402 and 784)
Summary: compiler crash with mixin and forward reference (Issue 402 and 784)
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 Windows
: P2 normal
Assignee: No Owner
URL:
Keywords: ice-on-invalid-code, patch
Depends on:
Blocks: 340
  Show dependency treegraph
 
Reported: 2009-08-19 19:09 UTC by Kenneth Switala
Modified: 2015-06-09 01:28 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Kenneth Switala 2009-08-19 19:09:52 UTC
this is slightly different code from Issue 402 and Issue 784, but it causes the compiler to freeze in DMD 1.046 and 2.032:

> dmd -c Conflicts.d
Conflicts.d(12): Error: mixin Conflicts.foo.BadImpl!(uint,Mix1) cannot resolve forward reference
Conflicts.d(12): Error: mixin Conflicts.foo.BadImpl!(uint,Mix1) cannot resolve forward reference

--- Conflicts.d ----

template BadImpl(T, alias thename)
{
  void a_bad_idea(T t)
  {
    thename.a_bad_idea(t);
  }
}

class foo
{
  mixin BadImpl!(uint,Mix1) Mix1;
}

int main()
{
  return 0;
}
Comment 1 Don 2009-08-25 02:30:46 UTC
Here's a superficial patch. If an error occurs while determining the arguments, it shouldn't try to determine which template is intended.


Patch: template.c, line 4542.
--------
    // Run semantic on each argument, place results in tiargs[]
+    int olderrors = global.errors;
    semanticTiargs(sc);
+    if (global.errors != olderrors) return; // Quit immediately if error occurs in argument

    tempdecl = findBestMatch(sc);
    if (!tempdecl)
    {	inst = this;
	return;		// error recovery
    }
Comment 2 Stewart Gordon 2009-08-25 11:29:12 UTC
I guess this counts as an actual forward reference bug, given that Mix1 is kind-of a forward reference....

(This seems to be a variation of CRTP.)

(In reply to comment #0)
> this is slightly different code from Issue 402 and Issue 784, but 
> it causes the compiler to freeze in DMD 1.046 and 2.032:

Uh, 2.032 doesn't seem to have been released yet.
Comment 3 Walter Bright 2009-10-13 13:46:43 UTC
Fixed dmd 1.049 and 2.034