Bug 236 – Class literal expression always says "base classes expected"

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2006-07-02T18:35:00Z
Last change time
2014-02-15T13:19:09Z
Keywords
rejects-valid
Assigned to
bugzilla
Creator
jarrett.billingsley

Comments

Comment #0 by jarrett.billingsley — 2006-07-02T18:35:48Z
I never ran into this before, and I kind of wonder why. void delegate() foo() { return &(new class { void dg() { writefln("delegate!"); } }).dg; } This gives the error "base classes expected" for the class literal. I guess I never ran into it because all the class literals I ever wrote derived from other classes. I tried this in several versions of DMD all the way back to 0.126, and they all give the same error. According to the spec, base classes are optional for class literals. I should be able to write "new class {}" and it should be fine. The semantic equivalent works just fine: void delegate() foo() { class fofof { void dg() { writefln("delegate!"); } } return &(new fofof).dg; }
Comment #1 by jpelcis — 2006-07-18T16:38:59Z
Fixed DMD 0.163.
Comment #2 by thomas-dloop — 2006-08-15T04:57:18Z
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 [email protected] schrieb am 2006-07-02: > http://d.puremagic.com/issues/show_bug.cgi?id=236 > I never ran into this before, and I kind of wonder why. > > void delegate() foo() > { > return &(new class > { > > void dg() > { > writefln("delegate!"); > } > }).dg; > } > > This gives the error "base classes expected" for the class literal. I guess I > never ran into it because all the class literals I ever wrote derived from > other classes. I tried this in several versions of DMD all the way back to > 0.126, and they all give the same error. According to the spec, base classes > are optional for class literals. I should be able to write "new class {}" and > it should be fine. > > The semantic equivalent works just fine: > > void delegate() foo() > { > class fofof > { > void dg() > { > writefln("delegate!"); > } > } > > return &(new fofof).dg; > } Added to DStress as http://dstress.kuehne.cn/run/c/class_26_A.d http://dstress.kuehne.cn/run/c/class_26_B.d Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFE4Z86LK5blCcjpWoRAnVaAJ91paqlf+5cmbO8IhSRRAdOHuMnEQCdE8Lp /MUhZsGnq18Le2uppLjHkdE= =z9aB -----END PGP SIGNATURE-----