Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,9 @@ bool validateUseDefs(str moduleName, map[str, tuple[int, set[int]]] defuses, Mod
if(!occ[u]?){
throw "Missing use <u> for <v>";
}
if(!any(use <- tm.uses, occ[u] == use.occ)){
throw "Missing `Use` value for use <u> of <v>";
}
potentialDefs = foundUseDefs[occ[u]];
if(isEmpty(potentialDefs) || !any(d <- potentialDefs, occ[def] == (tm.logical2physical[d] ? d))){
throw "Missing def for use <u> of <v>";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
;
}
}

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}>));
Loading