Skip to content

Commit b367022

Browse files
authored
fix: unbounded recursion in roxygen2 extraction (#2198)
refactor: fix recursion in roxygen2 extraction
1 parent 0d2ce84 commit b367022

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/r-bridge/roxygen2/documentation-provider.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,14 @@ export function getDocumentationOf(nodeId: NodeId, idMap: AstIdMap<ParentInforma
4949
const node = idMap.get(nodeId);
5050
if(!node) {
5151
return undefined;
52-
} else if(node.info.doc) {
52+
} else if('doc' in node.info) {
5353
return node.info.doc;
5454
}
5555
const retriever = CommentRetriever[node.type as RType] ?? ((c: RNode<ParentInformation>, a: AstIdMap) => parseRoxygenCommentsOfNode(c, a)?.tags);
5656
const doc = retriever(node as never, idMap);
5757
if(doc) {
58+
// to avoid endless recursion, we block the caching here once:
59+
(node.info as DocumentationInfo).doc = undefined;
5860
// cache the documentation for future queries
5961
const expanded = expandInheritsOfTags(doc, idMap);
6062
(node.info as DocumentationInfo).doc = expanded;

0 commit comments

Comments
 (0)