)]}' { "commit": "da3f3a3ab13fb335b525d74a38e6a8634a117fe5", "tree": "818c72154e1969c1f093fa06e00b831e87830449", "parents": [ "57853405463dd985dd49a2f14fb78bbf3595b1df" ], "author": { "name": "Adrian Taylor", "email": "ade@hohum.me.uk", "time": "Sun Oct 03 09:35:10 2021 -0700" }, "committer": { "name": "Emilio Cobos Álvarez", "email": "emilio@crisal.io", "time": "Wed Oct 27 19:23:31 2021 +0200" }, "message": "Avoid case of a self-referential type alias.\n\nThis previously produced a type alias which referred to itself,\nwhich was clearly wrong and resulted in downstream code recursing\ninfinitely.\n\nThe problem case (per bug #2102) is:\n\n template \u003ctypename\u003e class B{};\n template \u003ctypename c\u003e class C {\n public:\n using U \u003d B\u003cc\u003e;\n };\n class A : C\u003cA\u003e {\n U u;\n };\n\nAs far as I can tell, we parse clang\u0027s definition of B\u003cA\u003e; that leads\nus to parse A; to find it has a field U which turns out to be of type\nB\u003cA\u003e. And so we hit the line in item.rs which says:\n debug!(\"Avoiding recursion parsing type: {:?}\", ty);\nand bail out, returning the original item ID: hence, a self-\nreferential typedef is created.\n\nThe \u0027fix\u0027 in this PR creates an opaque type in this case instead,\nto avoid later infinite loops. It would be preferable to avoid this\nsituation in the first place, but presumably that would require\nus to split the parsing phase into two:\n1) types\n2) fields within those types.\n\nFixes #2102.\n", "tree_diff": [ { "type": "modify", "old_id": "9cfbd7a92235c0b727d3f2eabd2e6bf1a40ceaac", "old_mode": 33188, "old_path": "src/ir/ty.rs", "new_id": "d573408c3b3d3515791798cda3fc2a1efc81a384", "new_mode": 33188, "new_path": "src/ir/ty.rs" }, { "type": "add", "old_id": "0000000000000000000000000000000000000000", "old_mode": 0, "old_path": "/dev/null", "new_id": "4a799ef8e522db85817a8b62aace462b1ee320a9", "new_mode": 33188, "new_path": "tests/expectations/tests/constified-enum-module-overflow.rs" }, { "type": "add", "old_id": "0000000000000000000000000000000000000000", "old_mode": 0, "old_path": "/dev/null", "new_id": "d48f2be1b238077902f5f9016aea724e91108f38", "new_mode": 33188, "new_path": "tests/headers/constified-enum-module-overflow.hpp" } ] }