Skip to content

Commit ac25557

Browse files
committed
SliceRef also needs the slice element type
1 parent 22689c2 commit ac25557

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

goose.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -901,8 +901,9 @@ func (ctx Ctx) unaryExpr(e *ast.UnaryExpr) coq.Expr {
901901
if e.Op == token.AND {
902902
if x, ok := e.X.(*ast.IndexExpr); ok {
903903
// e is &a[b] where x is a.b
904-
if _, ok := ctx.typeOf(x.X).(*types.Slice); ok {
904+
if xTy, ok := ctx.typeOf(x.X).(*types.Slice); ok {
905905
return coq.NewCallExpr("SliceRef",
906+
ctx.coqTypeOfType(e, xTy.Elem()),
906907
ctx.expr(x.X), ctx.expr(x.Index))
907908
}
908909
}

internal/examples/semantics/semantics.gold.v

+1-1
Original file line numberDiff line numberDiff line change
@@ -1265,7 +1265,7 @@ Definition testSliceOps: val :=
12651265
let: "v1" := SliceGet uint64T "x" #2 in
12661266
let: "v2" := SliceSubslice uint64T "x" #2 #3 in
12671267
let: "v3" := SliceTake "x" #3 in
1268-
let: "v4" := SliceRef "x" #2 in
1268+
let: "v4" := SliceRef uint64T "x" #2 in
12691269
let: "ok" := ref_to boolT #true in
12701270
"ok" <-[boolT] (![boolT] "ok") && ("v1" = #10);;
12711271
"ok" <-[boolT] (![boolT] "ok") && (SliceGet uint64T "v2" #0 = #10);;

internal/examples/unittest/unittest.gold.v

+2-2
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,7 @@ Definition sliceOps: val :=
752752
let: "v1" := SliceGet uint64T "x" #2 in
753753
let: "v2" := SliceSubslice uint64T "x" #2 #3 in
754754
let: "v3" := SliceTake "x" #3 in
755-
let: "v4" := SliceRef "x" #2 in
755+
let: "v4" := SliceRef uint64T "x" #2 in
756756
"v1" + SliceGet uint64T "v2" #0 + SliceGet uint64T "v3" #1 + ![uint64T] "v4".
757757

758758
Definition makeSingletonSlice: val :=
@@ -769,7 +769,7 @@ Definition sliceOfThings := struct.decl [
769769

770770
Definition sliceOfThings__getThingRef: val :=
771771
rec: "sliceOfThings__getThingRef" "ts" "i" :=
772-
SliceRef (struct.get sliceOfThings "things" "ts") "i".
772+
SliceRef (struct.t thing) (struct.get sliceOfThings "things" "ts") "i".
773773

774774
Definition makeAlias: val :=
775775
rec: "makeAlias" <> :=

0 commit comments

Comments
 (0)