$ dmd -c foo.d
invalid op 32 94
Illegal instruction (core dumped)
The error goes away if I comment out either of F0, F1..5
The error also goes away if I use a non-templatized version of opCmp -- as in int opCmp(bar other)
// foo.d
enum foo {
// No error if one of these is commented out
F0 = bar(0),
F1 = bar(1),
F2 = bar(2),
F3 = bar(3),
F4 = bar(4),
F5 = bar(5)
}
struct bar {
int _val;
this(int val) { _val = val; }
int opCmp(U)(U other) {
if (_val == other._val) return 0;
if (_val > other._val) return 1;
else return -1;
}
}
struct frop(T) {
enum _elems = getSortedMembers!T;
static T[] getSortedMembers(T)() {
import std;
return array([EnumMembers!T].sort());
}
}
alias fropfoo = frop!foo;
Comment #1 by robert.schadek — 2024-12-13T19:31:04Z