From a26d384ce3e0cb3e16ae73eb103e7d0f397bc396 Mon Sep 17 00:00:00 2001 From: paulklint Date: Sat, 23 Mar 2024 17:31:22 +0100 Subject: [PATCH] Added type to variable declaration The variable topSort was introduced as `topSort = []` without declared type. It is assigned in the body of the local function strongConnect. However, we only do local type inference, not across function boundaries. As a result, at the return of stronglyConnectedComponentsAndTopSort, the inferred type of topSort is still list[void] and the returned tuple is rejected by the type checker. --- src/org/rascalmpl/library/analysis/graphs/Graph.rsc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/org/rascalmpl/library/analysis/graphs/Graph.rsc b/src/org/rascalmpl/library/analysis/graphs/Graph.rsc index ab7e6bff24c..dc9301f5c3a 100644 --- a/src/org/rascalmpl/library/analysis/graphs/Graph.rsc +++ b/src/org/rascalmpl/library/analysis/graphs/Graph.rsc @@ -67,8 +67,8 @@ tuple[set[set[&T]], list[&T]] stronglyConnectedComponentsAndTopSort(Graph[&T] g set[&T] onStack = {}; // set of nodes on current stack list[&T] stack = []; // node stack contains nodes of SCC under construction - components = {}; // set of SCCs to be constructed - topsort = []; + set[set[&T]]components = {};// set of SCCs to be constructed + list[&T] topsort = []; // sorted list of elements void strongConnect(&T v){ // Set the depth index for v to the smallest unused index