Repository: goplus/gop
Pull request #2018 (2024-11-20 23:33:31)

mini spec: Declarations and scope


Patch:
diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml
index 1647fd4c..ab059676 100644
--- a/.github/workflows/go.yml
+++ b/.github/workflows/go.yml
@@ -48,7 +48,7 @@ jobs:
       run: go test -v -coverprofile="coverage.txt" -covermode=atomic ./...
 
     - name: Codecov
-      uses: codecov/codecov-action@v5
+      uses: codecov/codecov-action@v4
       with:
         token: ${{ secrets.CODECOV_TOKEN }}
         slug: goplus/gop
diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml
index a90318a7..6f10496b 100644
--- a/.github/workflows/release-build.yml
+++ b/.github/workflows/release-build.yml
@@ -19,7 +19,7 @@ jobs:
         python .github/workflows/check_goreleaser_config.py
 
     - name: Install Snapcraft
-      uses: samuelmeuli/action-snapcraft@v3
+      uses: samuelmeuli/action-snapcraft@v2
 
     - name: Checkout tag
       run: |
diff --git a/doc/spec-mini.md b/doc/spec-mini.md
index 7e018279..d24ae029 100644
--- a/doc/spec-mini.md
+++ b/doc/spec-mini.md
@@ -1737,7 +1737,37 @@ println
 ...
 ```
 
-## Functions
+## Declarations and scope
+
+A _declaration_ binds a non-[blank]() identifier to a [constant](), [type](), [variable](), [function](), [label](), or [package](). Every identifier in a program must be declared. No identifier may be declared twice in the same block, and no identifier may be declared in both the file and package block.
+
+The [blank identifier]() may be used like any other identifier in a declaration, but it does not introduce a binding and thus is not declared. In the package block, the identifier `init` may only be used for [init function]() declarations, and like the blank identifier it does not introduce a new binding.
+
+```go
+Declaration   = ConstDecl | TypeDecl | VarDecl .
+TopLevelDecl  = Declaration | FunctionDecl .
+```
+
+The scope of a declared identifier is the extent of source text in which the identifier denotes the specified constant, type, variable, function, label, or package.
+
+Go+ is lexically scoped using blocks:
+
+* The scope of a [predeclared identifier]() is the universe block.
+* The scope of an identifier denoting a constant, type, variable, or function declared at top level (outside any function) is the package block.
+* The scope of the package name of an imported package is the file block of the file containing the import declaration.
+* The scope of an identifier denoting function parameter, or result variable is the function body.
+* The scope of a constant or variable identifier declared inside a function begins at the end of the `ConstSpec` or `VarSpec` (`ShortVarDecl` for short variable declarations) and ends at the end of the innermost containing block.
+
+An identifier declared in a block may be redeclared in an inner block. While the identifier of the inner declaration is in scope, it denotes the entity declared by the inner declaration.
+
+The [package clause]() is not a declaration; the package name does not appear in any scope. Its purpose is to identify the files belonging to the same [package](#packages) and to specify the default package name for import declarations.
+
+### Label scopes
+
+TODO
+
+
+### Function declarations
 
 A function declaration binds an identifier, the function name, to a function.
 
@@ -1760,6 +1790,7 @@ func IndexRune(s string, r rune) int {
 }
 ```
 
+
 ## Packages
 
 Go+ programs are constructed by linking together packages. A package in turn is constructed from one or more source files that together declare constants, types, variables and functions belonging to the package and which are accessible in all files of the same package. Those elements may be [exported]() and used in another package.
diff --git a/go.mod b/go.mod
index 4a815a6b..3a5d2782 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.3-0.20241112142719-46167891a7ee
+	github.com/goplus/gogen v1.16.2-0.20241108030022-38cdc04c7425
 	github.com/goplus/llgo v0.9.7
 	github.com/goplus/mod v0.13.12
 	github.com/qiniu/x v1.13.10
diff --git a/go.sum b/go.sum
index 41a6e1a4..f5a4f1c3 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.3-0.20241112142719-46167891a7ee h1:lwV/kdyMI18qF70vd+ur2/rAdmoA+Zy+c/btdDiiYt8=
-github.com/goplus/gogen v1.16.3-0.20241112142719-46167891a7ee/go.mod h1:6TQYbabXDF9LCdDkOOzHmfg1R4ENfXQ3XpHa9RhTSD8=
+github.com/goplus/gogen v1.16.2-0.20241108030022-38cdc04c7425 h1:sbzi0nY672ZJJCaNVez31tryu0otBL/5WfZ6UQ61M4I=
+github.com/goplus/gogen v1.16.2-0.20241108030022-38cdc04c7425/go.mod h1:6TQYbabXDF9LCdDkOOzHmfg1R4ENfXQ3XpHa9RhTSD8=
 github.com/goplus/llgo v0.9.7 h1:LRF2Fq9ts4QrVxOPZufexalbIoJ1oiBERjCWQ45wxbg=
 github.com/goplus/llgo v0.9.7/go.mod h1:5Fs+08NslqofJ7xtOiIXugkurYOoQvY02ZkFNWA1uEI=
 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 04742bf2..be836b38 100644
--- a/cl/compile_gop_test.go
+++ b/cl/compile_gop_test.go
@@ -1597,36 +1597,3 @@ func main() {
 }
 `)
 }
-
-func TestEmbedField(t *testing.T) {
-	gopClTest(t, `package main
-
-type Info struct {
-	id int
-}
-type T struct {
-	Info
-	id string
-}
-func demo(t *T) {
-	t.id = "0"
-}
-func main() {
-}
-`, `package main
-
-type Info struct {
-	id int
-}
-type T struct {
-	Info
-	id string
-}
-
-func demo(t *T) {
-	t.id = "0"
-}
-func main() {
-}
-`)
-}