Skip to content

Commit

Permalink
Fix yet another alias handling issue
Browse files Browse the repository at this point in the history
  • Loading branch information
tchajed committed Feb 28, 2025
1 parent 44ed00d commit f0004d0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
7 changes: 7 additions & 0 deletions internal/examples/semantics/conversions.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,10 @@ func testByteSliceToString() bool {
x[2] = 67
return byteSliceToString(x) == "ABC"
}

type args = string

func testStringToByteSliceAlias() bool {
x := args("ABC")
return []byte(x)[0] == 65
}
7 changes: 7 additions & 0 deletions internal/examples/semantics/semantics.gold.v
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,13 @@ Definition testByteSliceToString: val :=
SliceSet byteT "x" #2 #(U8 67);;
(byteSliceToString "x") = #(str"ABC").

Notation args := stringT (only parsing).

Definition testStringToByteSliceAlias: val :=
rec: "testStringToByteSliceAlias" <> :=
let: "x" := #(str"ABC") in
(SliceGet byteT (StringToBytes "x") #0) = #(U8 65).

(* copy.go *)

Definition testCopySimple: val :=
Expand Down
4 changes: 2 additions & 2 deletions types.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ func isProphId(t types.Type) bool {
}

func isByteSlice(t types.Type) bool {
if t, ok := t.(*types.Slice); ok {
if t, ok := types.Unalias(t).(*types.Slice); ok {
if elTy, ok := t.Elem().(*types.Basic); ok {
return elTy.Name() == "byte"
}
Expand All @@ -281,7 +281,7 @@ func isByteSlice(t types.Type) bool {
}

func isString(t types.Type) bool {
if t, ok := t.(*types.Basic); ok {
if t, ok := types.Unalias(t).(*types.Basic); ok {
return t.Name() == "string"
}
return false
Expand Down

0 comments on commit f0004d0

Please sign in to comment.