Hi,
I have a tagged union to represent an Expression on an AST.
pub const Expression = union(enum) {
const Self = @This();
infixExpression: InfixExpression,
identifier: Identifier,
integerLiteral: IntegerLiteral,
booleanLiteral: BooleanLiteral,
prefixExpression: PrefixExpression,
// more code
}```
`PrefixExpression` has a pointer to `Expression`
pub const PrefixExpression = struct {
const Self = @This();
token: Token,
operator: []const u8,
right: ?*const Expression,
// more code
If I create a `PrefixExpression` I can safely recover the `right` Expression that is being referenced, but once my prefixExpression is passed to a different function I cannot recover it anymore and the active member is always `infixExpression`.
AFAIK in order to preserve the correct value I need a `packed` union but there are no packed tagged unions. Am I missing something? am I doing something wrong?
Thanks .