Skip to content

Commit 220ebeb

Browse files
author
Christine Zhou
committed
Fixing "set key not found in map" error
1 parent 5da26ab commit 220ebeb

File tree

3 files changed

+45
-1
lines changed
  • Src
    • PChecker/CheckerCore/PRuntime/Values
    • PCompiler/CompilerCore/TypeChecker
  • Tst/RegressionTests/Integration/Correct/TestMapSet

3 files changed

+45
-1
lines changed

Src/PChecker/CheckerCore/PRuntime/Values/PrtSet.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,19 @@ private bool IsDirty
3737
}
3838
}
3939

40+
public override int GetHashCode()
41+
{
42+
if (!IsDirty)
43+
{
44+
return hashCode;
45+
}
46+
47+
hashCode = ComputeHashCode();
48+
IsDirty = false;
49+
50+
return hashCode;
51+
}
52+
4053
public IEnumerator<IPrtValue> GetEnumerator()
4154
{
4255
return set.GetEnumerator();

Src/PCompiler/CompilerCore/TypeChecker/Scope.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
using System;
12
using System.Collections.Generic;
23
using System.Diagnostics;
4+
using System.IO;
35
using System.Linq;
46
using Antlr4.Runtime;
57
using Plang.Compiler.TypeChecker.AST;
@@ -603,7 +605,7 @@ public SafetyTest Put(string name, PParser.SafetyTestDeclContext tree)
603605
string filePath = config.LocationResolver.GetLocation(tree).File.FullName;
604606
foreach (var dependencyPath in config.ProjectDependencies)
605607
{
606-
if (filePath.StartsWith(dependencyPath))
608+
if (filePath.StartsWith($"{dependencyPath}{Path.DirectorySeparatorChar}"))
607609
{
608610
return null;
609611
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Recreating set in map error
2+
3+
machine Main
4+
{
5+
start state Init {
6+
entry {
7+
ReplicateMapSet();
8+
}
9+
}
10+
}
11+
12+
fun ReplicateMapSet()
13+
{
14+
var seqmap: map[seq[int], int]; // Creating example for comparison
15+
var mapmap: map[map[int, int], int];
16+
var setmap: map[set[int], int];
17+
18+
seqmap[default(seq[int])] = 0;
19+
mapmap[default(map[int,int])] = 1;
20+
setmap[default(set[int])] = 2;
21+
22+
print format("seqmap: {0}", seqmap[default(seq[int])]);
23+
print format("mapmap: {0}", mapmap[default(map[int,int])]);
24+
print format("setmap: {0}", setmap[default(set[int])]);
25+
}
26+
27+
// module TestMapSet = { TestMapSet };
28+
29+
// test tcMapSet [main=TestMapSet]: TestMapSet;

0 commit comments

Comments
 (0)