Skip to content

Commit

Permalink
Fix type table bug in Conversion (#8017)
Browse files Browse the repository at this point in the history
- Clear the type table when going into a new class, to avoid
  accumulating every variable in the whole library.
  • Loading branch information
perost committed Oct 19, 2021
1 parent a1008d6 commit de71224
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions OMCompiler/Compiler/Script/Conversion.mo
Expand Up @@ -2754,6 +2754,8 @@ protected
input list<Absyn.ClassPart> parts;
input TypeTable components;
algorithm
UnorderedMap.clear(components);

for part in parts loop
() := match part
case Absyn.ClassPart.PUBLIC()
Expand Down
9 changes: 9 additions & 0 deletions OMCompiler/Compiler/Util/UnorderedMap.mo
Expand Up @@ -262,6 +262,15 @@ public
Vector.apply(map.buckets, function update_indices(removedIndex = index));
end remove;

function clear
input UnorderedMap<K, V> map;
algorithm
Vector.clear(map.buckets);
Vector.push(map.buckets, {});
Vector.clear(map.keys);
Vector.clear(map.values);
end clear;

function get
"Returns SOME(value) if the given key has an associated value in the map,
otherwise NONE()."
Expand Down

0 comments on commit de71224

Please sign in to comment.