Is &Node{ .atom = 0}
a dangling pointer here or does it share the lifetime of its parent Node
?
fn exprBindingPower(allocator: std.mem.Allocator, ... ) *Node {
var left_ptr = allocator.create(Node) catch unreachable;
left_ptr.* = switch (lexer_ptr.next()) {
.atom => |ch| Node{ .atom = ch },
.op => |op| blk: {
const bp = BindingPower.prefix(op);
const right_ptr = exprBindingPower(...);
break :blk Node{
.cons = .{
.left = &Node{ .atom = 0 }, // dubious lifetime
.op = op,
.right = right_ptr,
},
};
},
// ...
};
// ...
return left_ptr;
}