Skip to content
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
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
test:
strategy:
matrix:
go-version: ["1.25.x"]
go-version: ["1.26.x"]
os: ["ubuntu-latest"]
runs-on: ${{ matrix.os }}
steps:
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/goose-lang/goose

go 1.25
go 1.26

require (
github.com/fatih/color v1.18.0
Expand Down
2 changes: 1 addition & 1 deletion go.work
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
go 1.25.4
go 1.26

use (
.
Expand Down
3 changes: 2 additions & 1 deletion goose.go
Original file line number Diff line number Diff line change
Expand Up @@ -968,7 +968,8 @@ func (ctx *Ctx) indexExpr(e *ast.IndexExpr, multipleBindings bool) glang.Expr {

return glang.NewCallExpr(glang.VerbatimExpr("Index"),
ctx.glangType(e, ctx.typeOf(e.X)),
glang.TupleExpr{ctx.expr(e.X), ctx.expr(e.Index)})
glang.TupleExpr{ctx.expr(e.X),
ctx.exprIntoType(e.Index, types.Typ[types.Int])})
}

func (ctx *Ctx) indexListExpr(e *ast.IndexListExpr) glang.Expr {
Expand Down
2 changes: 2 additions & 0 deletions testdata/examples/append_log/append_log.gold.v
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Module append_log.

Definition Log {ext : ffi_syntax} {go_gctx : GoGlobalContext} : go.type := go.Named "github.com/goose-lang/goose/testdata/examples/append_log.Log"%go [].

#[global] Opaque Log.

Definition Init {ext : ffi_syntax} {go_gctx : GoGlobalContext} : go_string := "github.com/goose-lang/goose/testdata/examples/append_log.Init"%go.

Definition Open {ext : ffi_syntax} {go_gctx : GoGlobalContext} : go_string := "github.com/goose-lang/goose/testdata/examples/append_log.Open"%go.
Expand Down
10 changes: 10 additions & 0 deletions testdata/examples/channel/channel.gold.v
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,24 @@ Module chan_spec_raw_examples.

Definition LockedStack {ext : ffi_syntax} {go_gctx : GoGlobalContext} : go.type := go.Named "github.com/goose-lang/goose/testdata/examples/channel.LockedStack"%go [].

#[global] Opaque LockedStack.

Definition EliminationStack {ext : ffi_syntax} {go_gctx : GoGlobalContext} : go.type := go.Named "github.com/goose-lang/goose/testdata/examples/channel.EliminationStack"%go [].

#[global] Opaque EliminationStack.

Definition request {ext : ffi_syntax} {go_gctx : GoGlobalContext} : go.type := go.Named "github.com/goose-lang/goose/testdata/examples/channel.request"%go [].

#[global] Opaque request.

Definition stream {ext : ffi_syntax} {go_gctx : GoGlobalContext} : go.type := go.Named "github.com/goose-lang/goose/testdata/examples/channel.stream"%go [].

#[global] Opaque stream.

Definition streamold {ext : ffi_syntax} {go_gctx : GoGlobalContext} : go.type := go.Named "github.com/goose-lang/goose/testdata/examples/channel.streamold"%go [].

#[global] Opaque streamold.

Definition timeout {ext : ffi_syntax} {go_gctx : GoGlobalContext} : val := #(W64 10000).

Definition NewLockedStack {ext : ffi_syntax} {go_gctx : GoGlobalContext} : go_string := "github.com/goose-lang/goose/testdata/examples/channel.NewLockedStack"%go.
Expand Down
2 changes: 2 additions & 0 deletions testdata/examples/comments/comments.gold.v
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Module comments.

Definition Foo {ext : ffi_syntax} {go_gctx : GoGlobalContext} : go.type := go.Named "github.com/goose-lang/goose/testdata/examples/comments.Foo"%go [].

#[global] Opaque Foo.

Definition ONE {ext : ffi_syntax} {go_gctx : GoGlobalContext} : val := #(W64 1).

Definition TWO {ext : ffi_syntax} {go_gctx : GoGlobalContext} : val := #(W64 2).
Expand Down
2 changes: 1 addition & 1 deletion testdata/examples/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/goose-lang/goose/testdata/examples

go 1.25
go 1.26

require (
github.com/goose-lang/primitive v0.2.2-0.20260212023729-cb7f52217e65
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,16 @@ Module interfacerecursion.

Definition A {ext : ffi_syntax} {go_gctx : GoGlobalContext} : go.type := go.Named "github.com/goose-lang/goose/testdata/examples/interfacerecursion.A"%go [].

#[global] Opaque A.

Definition B {ext : ffi_syntax} {go_gctx : GoGlobalContext} : go.type := go.Named "github.com/goose-lang/goose/testdata/examples/interfacerecursion.B"%go [].

#[global] Opaque B.

Definition c {ext : ffi_syntax} {go_gctx : GoGlobalContext} : go.type := go.Named "github.com/goose-lang/goose/testdata/examples/interfacerecursion.c"%go [].

#[global] Opaque c.

(* go: x.go:14:13 *)
Definition c__Fooⁱᵐᵖˡ {ext : ffi_syntax} {go_gctx : GoGlobalContext} : val :=
λ: "c" <>,
Expand Down
4 changes: 4 additions & 0 deletions testdata/examples/logging2/logging2.gold.v
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@ Module logging2.

Definition Log {ext : ffi_syntax} {go_gctx : GoGlobalContext} : go.type := go.Named "github.com/goose-lang/goose/testdata/examples/logging2.Log"%go [].

#[global] Opaque Log.

Definition Txn {ext : ffi_syntax} {go_gctx : GoGlobalContext} : go.type := go.Named "github.com/goose-lang/goose/testdata/examples/logging2.Txn"%go [].

#[global] Opaque Txn.

Definition LOGCOMMIT {ext : ffi_syntax} {go_gctx : GoGlobalContext} : val := #(W64 0).

Definition LOGSTART {ext : ffi_syntax} {go_gctx : GoGlobalContext} : val := #(W64 1).
Expand Down
2 changes: 2 additions & 0 deletions testdata/examples/mapliteral/mapliteral.gold.v
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Module example.

Definition Nested {ext : ffi_syntax} {go_gctx : GoGlobalContext} : go.type := go.Named "github.com/goose-lang/goose/testdata/examples/mapliteral.Nested"%go [].

#[global] Opaque Nested.

Definition f {ext : ffi_syntax} {go_gctx : GoGlobalContext} : go_string := "github.com/goose-lang/goose/testdata/examples/mapliteral.f"%go.

Definition mapliteral {ext : ffi_syntax} {go_gctx : GoGlobalContext} : go_string := "github.com/goose-lang/goose/testdata/examples/mapliteral.mapliteral"%go.
Expand Down
72 changes: 72 additions & 0 deletions testdata/examples/semantics/semantics.gold.v
Original file line number Diff line number Diff line change
Expand Up @@ -14,76 +14,148 @@ Module semantics.

Definition unit {ext : ffi_syntax} {go_gctx : GoGlobalContext} : go.type := go.Named "github.com/goose-lang/goose/testdata/examples/semantics.unit"%go [].

#[global] Opaque unit.

Definition Editor {ext : ffi_syntax} {go_gctx : GoGlobalContext} : go.type := go.Named "github.com/goose-lang/goose/testdata/examples/semantics.Editor"%go [].

#[global] Opaque Editor.

Definition Pair {ext : ffi_syntax} {go_gctx : GoGlobalContext} : go.type := go.Named "github.com/goose-lang/goose/testdata/examples/semantics.Pair"%go [].

#[global] Opaque Pair.

Definition Uint32 {ext : ffi_syntax} {go_gctx : GoGlobalContext} : go.type := go.Named "github.com/goose-lang/goose/testdata/examples/semantics.Uint32"%go [].

#[global] Opaque Uint32.

Definition geometryInterface {ext : ffi_syntax} {go_gctx : GoGlobalContext} : go.type := go.Named "github.com/goose-lang/goose/testdata/examples/semantics.geometryInterface"%go [].

#[global] Opaque geometryInterface.

Definition SquareStruct {ext : ffi_syntax} {go_gctx : GoGlobalContext} : go.type := go.Named "github.com/goose-lang/goose/testdata/examples/semantics.SquareStruct"%go [].

#[global] Opaque SquareStruct.

Definition NumStruct {ext : ffi_syntax} {go_gctx : GoGlobalContext} : go.type := go.Named "github.com/goose-lang/goose/testdata/examples/semantics.NumStruct"%go [].

#[global] Opaque NumStruct.

Definition shapeInterface {ext : ffi_syntax} {go_gctx : GoGlobalContext} : go.type := go.Named "github.com/goose-lang/goose/testdata/examples/semantics.shapeInterface"%go [].

#[global] Opaque shapeInterface.

Definition polygonInterface {ext : ffi_syntax} {go_gctx : GoGlobalContext} : go.type := go.Named "github.com/goose-lang/goose/testdata/examples/semantics.polygonInterface"%go [].

#[global] Opaque polygonInterface.

Definition shapeStruct {ext : ffi_syntax} {go_gctx : GoGlobalContext} : go.type := go.Named "github.com/goose-lang/goose/testdata/examples/semantics.shapeStruct"%go [].

#[global] Opaque shapeStruct.

Definition polygonStruct {ext : ffi_syntax} {go_gctx : GoGlobalContext} : go.type := go.Named "github.com/goose-lang/goose/testdata/examples/semantics.polygonStruct"%go [].

#[global] Opaque polygonStruct.

Definition dogInterface {ext : ffi_syntax} {go_gctx : GoGlobalContext} : go.type := go.Named "github.com/goose-lang/goose/testdata/examples/semantics.dogInterface"%go [].

#[global] Opaque dogInterface.

Definition catInterface {ext : ffi_syntax} {go_gctx : GoGlobalContext} : go.type := go.Named "github.com/goose-lang/goose/testdata/examples/semantics.catInterface"%go [].

#[global] Opaque catInterface.

Definition Puppy {ext : ffi_syntax} {go_gctx : GoGlobalContext} : go.type := go.Named "github.com/goose-lang/goose/testdata/examples/semantics.Puppy"%go [].

#[global] Opaque Puppy.

Definition Kitten {ext : ffi_syntax} {go_gctx : GoGlobalContext} : go.type := go.Named "github.com/goose-lang/goose/testdata/examples/semantics.Kitten"%go [].

#[global] Opaque Kitten.

Definition printInterface {ext : ffi_syntax} {go_gctx : GoGlobalContext} : go.type := go.Named "github.com/goose-lang/goose/testdata/examples/semantics.printInterface"%go [].

#[global] Opaque printInterface.

Definition PaperStruct {ext : ffi_syntax} {go_gctx : GoGlobalContext} : go.type := go.Named "github.com/goose-lang/goose/testdata/examples/semantics.PaperStruct"%go [].

#[global] Opaque PaperStruct.

Definition Flower {ext : ffi_syntax} {go_gctx : GoGlobalContext} : go.type := go.Named "github.com/goose-lang/goose/testdata/examples/semantics.Flower"%go [].

#[global] Opaque Flower.

Definition Flora {ext : ffi_syntax} {go_gctx : GoGlobalContext} : go.type := go.Named "github.com/goose-lang/goose/testdata/examples/semantics.Flora"%go [].

#[global] Opaque Flora.

Definition Lily {ext : ffi_syntax} {go_gctx : GoGlobalContext} : go.type := go.Named "github.com/goose-lang/goose/testdata/examples/semantics.Lily"%go [].

#[global] Opaque Lily.

Definition Rose {ext : ffi_syntax} {go_gctx : GoGlobalContext} : go.type := go.Named "github.com/goose-lang/goose/testdata/examples/semantics.Rose"%go [].

#[global] Opaque Rose.

Definition Daisy {ext : ffi_syntax} {go_gctx : GoGlobalContext} : go.type := go.Named "github.com/goose-lang/goose/testdata/examples/semantics.Daisy"%go [].

#[global] Opaque Daisy.

Definition LoopStruct {ext : ffi_syntax} {go_gctx : GoGlobalContext} : go.type := go.Named "github.com/goose-lang/goose/testdata/examples/semantics.LoopStruct"%go [].

#[global] Opaque LoopStruct.

Definition BoolTest {ext : ffi_syntax} {go_gctx : GoGlobalContext} : go.type := go.Named "github.com/goose-lang/goose/testdata/examples/semantics.BoolTest"%go [].

#[global] Opaque BoolTest.

Definition ArrayEditor {ext : ffi_syntax} {go_gctx : GoGlobalContext} : go.type := go.Named "github.com/goose-lang/goose/testdata/examples/semantics.ArrayEditor"%go [].

#[global] Opaque ArrayEditor.

Definition Bar {ext : ffi_syntax} {go_gctx : GoGlobalContext} : go.type := go.Named "github.com/goose-lang/goose/testdata/examples/semantics.Bar"%go [].

#[global] Opaque Bar.

Definition Foo {ext : ffi_syntax} {go_gctx : GoGlobalContext} : go.type := go.Named "github.com/goose-lang/goose/testdata/examples/semantics.Foo"%go [].

#[global] Opaque Foo.

Definition TwoInts {ext : ffi_syntax} {go_gctx : GoGlobalContext} : go.type := go.Named "github.com/goose-lang/goose/testdata/examples/semantics.TwoInts"%go [].

#[global] Opaque TwoInts.

Definition S {ext : ffi_syntax} {go_gctx : GoGlobalContext} : go.type := go.Named "github.com/goose-lang/goose/testdata/examples/semantics.S"%go [].

#[global] Opaque S.

Definition StructWrap {ext : ffi_syntax} {go_gctx : GoGlobalContext} : go.type := go.Named "github.com/goose-lang/goose/testdata/examples/semantics.StructWrap"%go [].

#[global] Opaque StructWrap.

Definition StructWithFunc {ext : ffi_syntax} {go_gctx : GoGlobalContext} : go.type := go.Named "github.com/goose-lang/goose/testdata/examples/semantics.StructWithFunc"%go [].

#[global] Opaque StructWithFunc.

Definition switchConcrete {ext : ffi_syntax} {go_gctx : GoGlobalContext} : go.type := go.Named "github.com/goose-lang/goose/testdata/examples/semantics.switchConcrete"%go [].

#[global] Opaque switchConcrete.

Definition switchInterface {ext : ffi_syntax} {go_gctx : GoGlobalContext} : go.type := go.Named "github.com/goose-lang/goose/testdata/examples/semantics.switchInterface"%go [].

#[global] Opaque switchInterface.

Definition DefinedStr {ext : ffi_syntax} {go_gctx : GoGlobalContext} : go.type := go.Named "github.com/goose-lang/goose/testdata/examples/semantics.DefinedStr"%go [].

#[global] Opaque DefinedStr.

Definition List {ext : ffi_syntax} {go_gctx : GoGlobalContext} (T : go.type) : go.type := go.Named "github.com/goose-lang/goose/testdata/examples/semantics.List"%go [T].

#[global] Opaque List.

Definition Log {ext : ffi_syntax} {go_gctx : GoGlobalContext} : go.type := go.Named "github.com/goose-lang/goose/testdata/examples/semantics.Log"%go [].

#[global] Opaque Log.

Definition AdderType {ext : ffi_syntax} {go_gctx : GoGlobalContext} : go.type := go.FunctionType (go.Signature [go.uint64] false [go.uint64]).

Definition MultipleArgsType {ext : ffi_syntax} {go_gctx : GoGlobalContext} : go.type := go.FunctionType (go.Signature [go.uint64; go.bool] false [go.uint64]).
Expand Down
12 changes: 12 additions & 0 deletions testdata/examples/simpledb/simpledb.gold.v
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,28 @@ Module simpledb.

Definition Table {ext : ffi_syntax} {go_gctx : GoGlobalContext} : go.type := go.Named "github.com/goose-lang/goose/testdata/examples/simpledb.Table"%go [].

#[global] Opaque Table.

Definition Entry {ext : ffi_syntax} {go_gctx : GoGlobalContext} : go.type := go.Named "github.com/goose-lang/goose/testdata/examples/simpledb.Entry"%go [].

#[global] Opaque Entry.

Definition lazyFileBuf {ext : ffi_syntax} {go_gctx : GoGlobalContext} : go.type := go.Named "github.com/goose-lang/goose/testdata/examples/simpledb.lazyFileBuf"%go [].

#[global] Opaque lazyFileBuf.

Definition bufFile {ext : ffi_syntax} {go_gctx : GoGlobalContext} : go.type := go.Named "github.com/goose-lang/goose/testdata/examples/simpledb.bufFile"%go [].

#[global] Opaque bufFile.

Definition tableWriter {ext : ffi_syntax} {go_gctx : GoGlobalContext} : go.type := go.Named "github.com/goose-lang/goose/testdata/examples/simpledb.tableWriter"%go [].

#[global] Opaque tableWriter.

Definition Database {ext : ffi_syntax} {go_gctx : GoGlobalContext} : go.type := go.Named "github.com/goose-lang/goose/testdata/examples/simpledb.Database"%go [].

#[global] Opaque Database.

Definition UseMarshal {ext : ffi_syntax} {go_gctx : GoGlobalContext} : go_string := "github.com/goose-lang/goose/testdata/examples/simpledb.UseMarshal"%go.

Definition CreateTable {ext : ffi_syntax} {go_gctx : GoGlobalContext} : go_string := "github.com/goose-lang/goose/testdata/examples/simpledb.CreateTable"%go.
Expand Down
10 changes: 10 additions & 0 deletions testdata/examples/unittest/generics/generics.gold.v
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,24 @@ Module generics.

Definition Box {ext : ffi_syntax} {go_gctx : GoGlobalContext} (T : go.type) : go.type := go.Named "github.com/goose-lang/goose/testdata/examples/unittest/generics.Box"%go [T].

#[global] Opaque Box.

Definition Container {ext : ffi_syntax} {go_gctx : GoGlobalContext} (T : go.type) : go.type := go.Named "github.com/goose-lang/goose/testdata/examples/unittest/generics.Container"%go [T].

#[global] Opaque Container.

Definition UseContainer {ext : ffi_syntax} {go_gctx : GoGlobalContext} : go.type := go.Named "github.com/goose-lang/goose/testdata/examples/unittest/generics.UseContainer"%go [].

#[global] Opaque UseContainer.

Definition OnlyIndirect {ext : ffi_syntax} {go_gctx : GoGlobalContext} (T : go.type) : go.type := go.Named "github.com/goose-lang/goose/testdata/examples/unittest/generics.OnlyIndirect"%go [T].

#[global] Opaque OnlyIndirect.

Definition MultiParam {ext : ffi_syntax} {go_gctx : GoGlobalContext} (A : go.type) (B : go.type) : go.type := go.Named "github.com/goose-lang/goose/testdata/examples/unittest/generics.MultiParam"%go [A; B].

#[global] Opaque MultiParam.

Definition UnderlyingSlice {ext : ffi_syntax} {go_gctx : GoGlobalContext} : go_string := "github.com/goose-lang/goose/testdata/examples/unittest/generics.UnderlyingSlice"%go.

Definition Clone {ext : ffi_syntax} {go_gctx : GoGlobalContext} : go_string := "github.com/goose-lang/goose/testdata/examples/unittest/generics.Clone"%go.
Expand Down
Loading