Skip to content

Commit

Permalink
fixed bug
Browse files Browse the repository at this point in the history
  • Loading branch information
shazqadeer committed Nov 23, 2023
1 parent 7cf52a3 commit 09a079c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Source/Core/Monomorphization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1830,6 +1830,13 @@ public static string MkInstanceName(string name, List<Type> actualTypeParams)
public Type LookupType(Type type)
{
type = TypeProxy.FollowProxy(type.Expanded);
if (type is MapType mapType && mapType.FreeVariables.Count == 0)
{
var instantiatedTypeArguments = mapType.Arguments.Select(x => LookupType(x)).ToList();
var instantiatedTypeResult = LookupType(mapType.Result);
return new MapType(Token.NoToken, new List<TypeVariable>(mapType.TypeParameters), instantiatedTypeArguments,
instantiatedTypeResult);
}
if (type is CtorType ctorType && ctorType.FreeVariables.Count == 0 &&
MonomorphismChecker.DoesTypeCtorDeclNeedMonomorphization(ctorType.Decl))
{
Expand Down
19 changes: 19 additions & 0 deletions Test/monomorphize/type-translation-bug.bpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// RUN: %parallel-boogie "%s" > "%t"
// RUN: %diff "%s.expect" "%t"

procedure {:inline 1} Copy<T>(v: T) returns (copy_v: T)
{
copy_v := v;
}

type Value;
type Round;
datatype Option<T> { None(), Some(t: T) }

var decision: [Round]Option Value;
procedure Foo()
modifies decision;
{
call decision := Copy((lambda r: Round :: None()));
assert decision == (lambda r: Round :: None());
}
2 changes: 2 additions & 0 deletions Test/monomorphize/type-translation-bug.bpl.expect
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

Boogie program verifier finished with 1 verified, 0 errors

0 comments on commit 09a079c

Please sign in to comment.