diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/check/Import.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/check/Import.rsc index 6b39268e7e..0c2bcb77be 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/check/Import.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/check/Import.rsc @@ -505,6 +505,7 @@ ModuleStatus doSaveModule(set[MODID] component, map[MODID,set[MODID]] m_imports, } }; + m1.uses = [u | Use u <- tm.uses, u.occ in m1.useDef<0>]; m1.defines = toSet(defs); m1.definitions = ( def.defined : def | Define def <- m1.defines); // TODO this is derived info, can we derive it later? diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/StaticTestingUtils.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/StaticTestingUtils.rsc index e6f587d002..6be1ae6b34 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/StaticTestingUtils.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/StaticTestingUtils.rsc @@ -247,6 +247,9 @@ bool validateUseDefs(str moduleName, map[str, tuple[int, set[int]]] defuses, Mod if(!occ[u]?){ throw "Missing use for "; } + if(!any(use <- tm.uses, occ[u] == use.occ)){ + throw "Missing `Use` value for use of "; + } potentialDefs = foundUseDefs[occ[u]]; if(isEmpty(potentialDefs) || !any(d <- potentialDefs, occ[def] == (tm.logical2physical[d] ? d))){ throw "Missing def for use of "; diff --git a/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/UseDefTests.rsc b/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/UseDefTests.rsc index 8a812d2854..a85dd06248 100644 --- a/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/UseDefTests.rsc +++ b/src/org/rascalmpl/compiler/lang/rascalcore/check/tests/UseDefTests.rsc @@ -107,4 +107,14 @@ test bool overloadedSyntaxField(){ return useDefOK(mtext, ("c": <0, {2}>)) // check uses of first declaration of c && useDefOK(mtext, ("c": <1, {3}>)) // check uses of first declaration of c ; -} \ No newline at end of file +} + +test bool issue2165() = + useDefOK("module Issue2165 + int f(int i) { + int x = 2; + return i * x; + } + void main() { + f(5); + }", ("x": <0, {1}>, "i": <0, {1}>, "f": <0, {1}>));