Repository: goplus/gop
Pull request #2046 (2024-12-26 00:23:37)

mini spec ebnf: Types


Patch:
diff --git a/.goreleaser.yaml b/.goreleaser.yaml
index 2553aacc..d96b74a3 100644
--- a/.goreleaser.yaml
+++ b/.goreleaser.yaml
@@ -51,7 +51,6 @@ dockers:
     build_flag_templates:
       - --platform=linux/386
       - --build-arg=USE_GORELEASER_ARTIFACTS=1
-      - --build-arg=GORELEASER_ARTIFACTS_TARBALL=./.dist/{{.ProjectName}}{{.Version}}.linux-386.tar.gz
     extra_files:
       - ./
   - goarch: amd64
@@ -61,7 +60,6 @@ dockers:
     build_flag_templates:
       - --platform=linux/amd64
       - --build-arg=USE_GORELEASER_ARTIFACTS=1
-      - --build-arg=GORELEASER_ARTIFACTS_TARBALL=./.dist/{{.ProjectName}}{{.Version}}.linux-amd64.tar.gz
     extra_files:
       - ./
   - goarch: arm64
@@ -71,7 +69,6 @@ dockers:
     build_flag_templates:
       - --platform=linux/arm64
       - --build-arg=USE_GORELEASER_ARTIFACTS=1
-      - --build-arg=GORELEASER_ARTIFACTS_TARBALL=./.dist/{{.ProjectName}}{{.Version}}.linux-arm64.tar.gz
     extra_files:
       - ./
 
diff --git a/Dockerfile b/Dockerfile
index 8b214ce7..bbca70c3 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -2,18 +2,21 @@ ARG BASE_IMAGE=golang:1.22-bookworm
 
 FROM $BASE_IMAGE AS build
 ARG USE_GORELEASER_ARTIFACTS=0
-ARG GORELEASER_ARTIFACTS_TARBALL
 WORKDIR /usr/local/src/gop
 COPY . .
 ENV GOPROOT=/usr/local/gop
 RUN set -eux; \
-	mkdir $GOPROOT; \
+	mkdir -p $GOPROOT/bin; \
+	git ls-tree --full-tree --name-only -r HEAD | grep -vE "^\." | xargs -I {} cp --parents {} $GOPROOT/; \
 	if [ $USE_GORELEASER_ARTIFACTS -eq 1 ]; then \
-		tar -xzf "${GORELEASER_ARTIFACTS_TARBALL}" -C $GOPROOT; \
+		GOARCH=$(go env GOARCH); \
+		BIN_DIR_SUFFIX=linux_$GOARCH; \
+		[ $GOARCH = "amd64" ] && BIN_DIR_SUFFIX=${BIN_DIR_SUFFIX}_v1; \
+		[ $GOARCH = "arm" ] && BIN_DIR_SUFFIX=${BIN_DIR_SUFFIX}_$(go env GOARM | cut -d , -f 1); \
+		cp .dist/gop_$BIN_DIR_SUFFIX/bin/gop $GOPROOT/bin/; \
 	else \
-		git ls-tree --full-tree --name-only -r HEAD | grep -vE "^\." | xargs -I {} cp --parents {} $GOPROOT/; \
 		./all.bash; \
-		mv bin $GOPROOT/; \
+		cp bin/gop $GOPROOT/bin/; \
 	fi
 
 FROM $BASE_IMAGE
diff --git a/doc/spec-mini.md b/doc/spec-mini.md
index a8c73193..5eb9dbdc 100644
--- a/doc/spec-mini.md
+++ b/doc/spec-mini.md
@@ -437,6 +437,19 @@ A variable's value is retrieved by referring to the variable in an [expression](
 
 ## Types
 
+A type determines a set of values together with operations and methods specific to those values. A type may be denoted by a _type name_. A type may also be specified using a type literal, which composes a type from existing types.
+
+```go
+Type      = TypeName | TypeLit | "(" Type ")" .
+TypeName  = identifier | QualifiedIdent .
+TypeLit   = ArrayType | StructType | PointerType | FunctionType | InterfaceType |
+            SliceType | MapType . // TODO: check this
+```
+
+The language [predeclares]() certain type names. Others are introduced with [type declarations](#type-declarations). _Composite types_—array, struct, pointer, function, interface, slice, map—may be constructed using type literals.
+
+Predeclared types and defined types are called _named types_. An alias denotes a named type if the type given in the alias declaration is a named type.
+
 ### Boolean types
 
 A _boolean type_ represents the set of Boolean truth values denoted by the predeclared constants true and false. The predeclared boolean type is `bool`; it is a defined type.
@@ -755,7 +768,7 @@ The equality operators == and != apply to operands of comparable types. The orde
 
 A comparison of two interface values with identical dynamic types causes a [run-time panic]() if that type is not comparable. This behavior applies not only to direct interface value comparisons but also when comparing arrays of interface values or structs with interface-valued fields.
 
-Slice, map, and function types are not comparable. However, as a special case, a slice, map, or function value may be compared to the predeclared identifier `nil`. Comparison of pointer, channel, and interface values to `nil` is also allowed and follows from the general rules above.
+Slice, map, and function types are not comparable. However, as a special case, a slice, map, or function value may be compared to the predeclared identifier `nil`. Comparison of pointer, and interface values to `nil` is also allowed and follows from the general rules above.
 
 #### Logical operators
 
@@ -1136,7 +1149,7 @@ a[i] <<= 2
 i &^= 1<<n
 ```
 
-A tuple assignment assigns the individual elements of a multi-valued operation to a list of variables. There are two forms. In the first, the right hand operand is a single multi-valued expression such as a function call, a channel or [map](#map-types) operation, or a [type assertion](). The number of operands on the left hand side must match the number of values. For instance, if f is a function returning two values,
+A tuple assignment assigns the individual elements of a multi-valued operation to a list of variables. There are two forms. In the first, the right hand operand is a single multi-valued expression such as a function call or [map](#map-types) operation, or a [type assertion](). The number of operands on the left hand side must match the number of values. For instance, if f is a function returning two values,
 
 ```go
 x, y = f()
@@ -1737,12 +1750,10 @@ len(s)    string type      string length in bytes
           [n]T, *[n]T      array length (== n)
           []T              slice length
           map[K]T          map length (number of defined keys)
-          chan T           number of elements queued in channel buffer
           type parameter   see below
 
 cap(s)    [n]T, *[n]T      array length (== n)
           []T              slice capacity
-          chan T           channel buffer capacity
           type parameter   see below
 ```
 
@@ -1752,7 +1763,7 @@ The capacity of a slice is the number of elements for which there is space alloc
 0 <= len(s) <= cap(s)
 ```
 
-The length of a `nil` slice, map or channel is `0`. The capacity of a `nil` slice or channel is `0`.
+The length of a `nil` slice, map is `0`. The capacity of a `nil` slice is `0`.
 
 The expression `len(s)` is [constant](#constants) if s is a string constant. The expressions `len(s)` and `cap(s)` are constants if the type of `s` is an array or pointer to an array and the expression `s` does not contain (non-constant) [function calls](#commands-and-calls); in this case `s` is not evaluated. Otherwise, invocations of `len` and `cap` are not constant and `s` is evaluated.
 
diff --git a/go.mod b/go.mod
index 10b3a11e..cbe3b4a8 100644
--- a/go.mod
+++ b/go.mod
@@ -4,7 +4,7 @@ go 1.18
 
 require (
 	github.com/fsnotify/fsnotify v1.8.0
-	github.com/goplus/gogen v1.16.4-0.20241205134824-ac870e207d8f
+	github.com/goplus/gogen v1.16.3
 	github.com/goplus/llgo v0.9.8
 	github.com/goplus/mod v0.13.12
 	github.com/qiniu/x v1.13.10
diff --git a/go.sum b/go.sum
index cead13c2..e1e847ac 100644
--- a/go.sum
+++ b/go.sum
@@ -1,7 +1,7 @@
 github.com/fsnotify/fsnotify v1.8.0 h1:dAwr6QBTBZIkG8roQaJjGof0pp0EeF+tNV7YBP3F/8M=
 github.com/fsnotify/fsnotify v1.8.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
-github.com/goplus/gogen v1.16.4-0.20241205134824-ac870e207d8f h1:+CwzStluc1MGjEQbR5CQOXWOqlBLYnaeECKcSXrHYKg=
-github.com/goplus/gogen v1.16.4-0.20241205134824-ac870e207d8f/go.mod h1:6TQYbabXDF9LCdDkOOzHmfg1R4ENfXQ3XpHa9RhTSD8=
+github.com/goplus/gogen v1.16.3 h1:nNkV1b6zd89d/UhMb4bZHcEfdAHtPaadrJFXNcoUITI=
+github.com/goplus/gogen v1.16.3/go.mod h1:6TQYbabXDF9LCdDkOOzHmfg1R4ENfXQ3XpHa9RhTSD8=
 github.com/goplus/llgo v0.9.8 h1:9qFO5sEYzTXYixNL9m9qDNfI2kjtnU3bPMf5hOwQlME=
 github.com/goplus/llgo v0.9.8/go.mod h1:1phqPJEgr/uw59PRz/NB7s54OoP+NGjC6pz0HovT5JY=
 github.com/goplus/mod v0.13.12 h1:Trwk6j3i9VvBuW6/9ZxmkoFlEL2v3HKQu0Na1c6DAdw=


Test patch:
diff --git a/cl/compile_gop_test.go b/cl/compile_gop_test.go
index 90bbdd66..04742bf2 100644
--- a/cl/compile_gop_test.go
+++ b/cl/compile_gop_test.go
@@ -1630,37 +1630,3 @@ func main() {
 }
 `)
 }
-
-func TestOverloadUntyped(t *testing.T) {
-	gopMixedClTest(t, "main", `
-package main
-
-type specialObj int
-type SpriteName string
-
-type SpriteImpl struct {
-}
-
-func (p *SpriteImpl) turn(v any) {
-}
-func (p *SpriteImpl) TurnTo__0(sprite *SpriteImpl) {
-}
-func (p *SpriteImpl) TurnTo__1(sprite SpriteName) {
-}
-func (p *SpriteImpl) TurnTo__2(obj specialObj) {
-}
-func (p *SpriteImpl) TurnTo__3(degree float64) {
-}
-`, `
-p := &SpriteImpl{}
-p.turnTo 180.0
-p.turnTo 180.1
-`, `package main
-
-func main() {
-	p := &SpriteImpl{}
-	p.TurnTo__2(180.0)
-	p.TurnTo__3(180.1)
-}
-`)
-}