Help needed for "recursive template expansion error"
Anthony Abeo
anthonyabeo at gmail.com
Mon Oct 21 18:14:11 UTC 2019
Hello all,
I have an Algebraic type of structs as shown below. One of the
structs is the `Code` struct and this struct holds an array of
ATTR_INFO. It is self-referential. Obviously the compiler is
unable to get the maximum size of ATTR_INFO at compile-time,
hence throwing the error. I will be very grateful for any help to
resolve this issue.
alias ATTR_INFO = Algebraic!(SourceFile, ConstantValue,
Excepsion, Code,
LineNumberTable, LocalVariableTable);
struct Code
{
size_t attribute_name_index;
size_t attribute_len;
size_t max_stack;
size_t max_locals;
size_t code_length;
const(ubyte[]) code;
size_t exception_table_length;
Tuple!(size_t, size_t, size_t, size_t) exception_table;
size_t attribute_count;
ATTR_INFO[] attributes;
}
STACK TRACE
/Library/D/dmd/src/phobos/std/variant.d(1517,23): Error: template
instance `VariantN!(maxSize!(SourceFile, ConstantV
alue, Excepsion, Code, LineNumberTable, LocalVariableTable), T)`
recursive template expansion
/Library/D/dmd/src/phobos/std/variant.d(87,48): Error: template
instance `std.variant.maxSize!(Code, LineNumberTable
, LocalVariableTable)` error instantiating
/Library/D/dmd/src/phobos/std/variant.d(87,48):
instantiated from here: maxSize!(Excepsion, Code, LineNumberT
able, LocalVariableTable)
/Library/D/dmd/src/phobos/std/variant.d(87,48):
instantiated from here: maxSize!(ConstantValue, Excepsion, Code,
LineNumberTable, LocalVariableTable)
/Library/D/dmd/src/phobos/std/variant.d(1517,33):
instantiated from here: maxSize!(SourceFile, ConstantValue,
Excepsion, Code, LineNumberTable, LocalVariableTable)
source/app.d(8,19): instantiated from here:
Algebraic!(SourceFile, ConstantValue, Excepsion, Code,
LineNumberTable, LocalVariableTable)
/Library/D/dmd/bin/dmd failed with exit code 1.
More information about the Digitalmars-d
mailing list