Regression tests for specific memory lifecycle and ownership bugs.
This test file targets specific, subtle bugs related to the memory lifecycle of infix_type objects, particularly when they are copied between different memory arenas during the "Parse -> Copy -> Resolve -> Layout" pipeline.
The tests verify:
- Use-After-Free of Pointee Types: Ensures that when a signature like
*@Point is parsed, the Point type object (resolved from the registry) remains valid and is not prematurely freed after the temporary parser arena is destroyed.
- Correct Printing of Copied Named Types: Verifies that
infix_type_print can correctly serialize a type graph that has been deep-copied into a trampoline's private arena, ensuring that pointers to type names remain valid after the copy.
- Handling of Recursive Types: Confirms that the deep-copy mechanism correctly handles recursive type definitions (like a linked list node) without causing a stack overflow from infinite recursion, and that the resulting copied graph maintains its correct recursive structure.
- Semantic Name Preservation: Validates that the new
name field is correctly populated and preserved through the full parse/copy/resolve pipeline for all named types, including aliases.