mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-02 19:32:17 +00:00
![]() If an entry in the layout cache contains recursive structures, the entry is not reusable if the recursive structure is currently in the "seen" set. The example elucidated in the source code is as follows: Suppose we are constructing the layout of ``` [A, B (List r)] as r ``` and we have already constructed and cached the layout of `List r`, which would be ``` List (Recursive [Unit, List RecursivePointer]) ``` If we use the cached entry of `List r`, we would end up with the layout ``` Recursive [Unit, (List (Recursive [Unit, List RecursivePointer]))] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cached layout for `List r` ``` but this is not correct; the canonical layout of `[A, B (List r)] as r` is ``` Recursive [Unit, (List RecursivePointer)] ``` However, the current implementation only preserves this behavior for structures that contain one recursive structure under them. In practice, there can be structures that contain multiple recursive structures under them, and we must be sure to record all those structures in the layout-cache. |
||
---|---|---|
.. | ||
generated | ||
src | ||
Cargo.toml |