Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue #489 #490

Merged
merged 2 commits into from
Jul 19, 2022
Merged
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 @@ -298,7 +298,7 @@ class ArrayEncoding extends TypeEncoding with SharedArrayEmbedding {
/**
* Generates:
* function arrayConversion(x: [([n]T)@]): ([n]T)°
* requires Footprint[x]
* requires acc(Footprint[x], _)
* ensures [x == result]
* */
private val conversionFunc: FunctionGenerator[ComponentParameter] = new FunctionGenerator[ComponentParameter]{
Expand All @@ -318,7 +318,7 @@ class ArrayEncoding extends TypeEncoding with SharedArrayEmbedding {
name = s"${Names.arrayConversionFunc}_${t.serialize}",
formalArgs = Vector(variable(ctx)(x)),
typ = vResultType,
pres = Vector(pure(addressFootprint(ctx)(x, in.FullPerm(Source.Parser.Internal)))(ctx).res),
pres = Vector(pure(addressFootprint(ctx)(x, in.WildcardPerm(Source.Parser.Internal)))(ctx).res),
posts = Vector(post),
body = None
)()
Expand Down
25 changes: 25 additions & 0 deletions src/test/resources/regressions/issues/000489.gobra
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Any copyright is dedicated to the Public Domain.
// http://creativecommons.org/publicdomain/zero/1.0/

package main

pred (t *T) Mem() {
acc(t) && t.Cons()
}

pred (t T) Cons() {
t.f[0] == 0
}

type T struct {
f [1]int
}

preserves acc(t.Mem(), 1/2)
func (t *T) foo() {
unfold acc(t.Mem(), 1/2)
unfold acc(t.Cons(), 1/2)
fold acc(t.Cons(), 1/2)
fold acc(t.Mem(), 1/2)
return
}