Bug 9718 – Circular reference with a simple Algebraic

Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2013-03-14T06:18:05Z
Last change time
2023-03-27T12:46:24Z
Keywords
rejects-valid
Assigned to
No Owner
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2013-03-14T06:18:05Z
import std.variant: Algebraic; Spam foo() { return Spam.init; } struct Bar { Spam baz() { return Spam.init; } } alias Algebraic!(Bar) Spam; void main() {} DMD 2.063alpha gives: Assertion failure: 'global.errors' on line 5886 in file 'template.c' If I swap foo() and Bar{} it compiles: import std.variant: Algebraic; struct Bar { Spam baz() { return Spam.init; } } Spam foo() { return Spam.init; } alias Algebraic!(Bar) Spam; void main() {}
Comment #1 by bearophile_hugs — 2013-03-14T11:32:07Z
Reduced test case: template Foo(T) { enum size_t Foo = T.sizeof; } Spam s1; struct Bar { Spam s2; } alias int[Foo!Bar] Spam; void main() {}
Comment #2 by yebblies — 2013-11-22T18:49:33Z
No longer ICEs
Comment #3 by razvan.nitu1305 — 2023-03-27T12:46:24Z
This now gives: variable `test.Foo!(Bar).Foo` recursive initialization of constant which makes sense because sizeof Bar is requested, which contains a Spam which is defined as a function of Foo which requires sizeof Bar etc.