Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can't append nil to a slice of interfaces #1136

Closed
thehowl opened this issue Sep 16, 2023 · 1 comment · Fixed by #1177
Closed

can't append nil to a slice of interfaces #1136

thehowl opened this issue Sep 16, 2023 · 1 comment · Fixed by #1177
Assignees
Labels
🐞 bug Something isn't working 📦 🤖 gnovm Issues or PRs gnovm related

Comments

@thehowl
Copy link
Member

thehowl commented Sep 16, 2023

package main

func main() {
        var errors []error
        errors = append(errors, nil)
        _ = errors
}
$ gno run a.gno
--- preprocess stack ---
stack 2: func main() { var errors<VPBlock(1,0)> [](const-type .uverse.error); errors<VPBlock(1,0)> = (const (append func(x <X>{},args MaybeNativeType{...<X.Elem()>{}})(res <X>{})))(error
s<VPBlock(1,0)>, (const (undefined))); _<VPUverse(0)> = errors<VPUverse(0)> }
stack 1: file{ package main; func main() { var errors<VPBlock(1,0)> [](const-type .uverse.error); errors<VPBlock(1,0)> = (const (append func(x <X>{},args MaybeNativeType{...<X.Elem()>{}}
)(res <X>{})))(errors<VPBlock(1,0)>, (const (undefined))); _<VPUverse(0)> = errors<VPUverse(0)> } }
stack 0: package(main)
------------------------
panic: unspecified generic varg args MaybeNativeType{...<X.Elem()>{}} [recovered]
        panic: main/a.gno:5: unspecified generic varg args MaybeNativeType{...<X.Elem()>{}}

goroutine 1 [running]:
github.com/gnolang/gno/gnovm/pkg/gnolang.Preprocess.func2.1()
        /home/howl/oc/gno/gnovm/pkg/gnolang/preprocess.go:173 +0x46d
panic({0xbf0b20, 0xc00007d560})
        /usr/lib/go/src/runtime/panic.go:890 +0x263
github.com/gnolang/gno/gnovm/pkg/gnolang.(*FuncType).Specify(0xc0000ac5f0, {0xf651b0, 0xc0001881b0}, {0xc0001b79a0, 0x2, 0x2}, 0x0)
        /home/howl/oc/gno/gnovm/pkg/gnolang/types.go:1174 +0x1a54
github.com/gnolang/gno/gnovm/pkg/gnolang.Preprocess.func2({0xc000212a00?, 0x3, 0x20}, 0x24, 0x40ae04?, {0xf5acf8, 0xc0002fd620?}, 0x3)
        /home/howl/oc/gno/gnovm/pkg/gnolang/preprocess.go:1096 +0x3c6e
github.com/gnolang/gno/gnovm/pkg/gnolang.transcribe(0xc0001a9970, {0xc000212a00?, 0x3, 0x20}, 0x24, 0xf5aaf0?, {0xf5acf8?, 0xc0002fd620}, 0xc0001a9217)
        /home/howl/oc/gno/gnovm/pkg/gnolang/transcribe.go:728 +0x4b63
github.com/gnolang/gno/gnovm/pkg/gnolang.transcribe(0xc0001a9970, {0xc000212a00?, 0x2, 0x20}, 0x46, 0xf5b170?, {0xf5aaf0?, 0xc0002fd680}, 0xc0001a9447)
        /home/howl/oc/gno/gnovm/pkg/gnolang/transcribe.go:371 +0x6e99
@thehowl
Copy link
Member Author

thehowl commented Sep 25, 2023

This may actually be the same issue (or at least, the same fix) as #1149

mvertes added a commit to mvertes/gno that referenced this issue Sep 27, 2023
This is a particular case of Go append builtin where the array
type is inferred from the first argument. We detect using untyped
nil as argument, then we convert it to the array type prior to
proceeed further. It fixes further consistency checks and value
generation.

Fixes gnolang#1136.
thehowl added a commit that referenced this issue Jan 10, 2024
This is a particular case of Go append builtin where the array type is
inferred from the first argument. We detect an untyped const passed as
argument, then we convert it to the array type prior to proceed further.
It fixes further consistency checks and value generation.

Fixes #1136, fixes #1149, fixes #1341.

<!-- please provide a detailed description of the changes made in this
pull request. -->

<details><summary>Contributors' checklist...</summary>

- [x] Added new tests, or not needed, or not feasible
- [x] Provided an example (e.g. screenshot) to aid review or the PR is
self-explanatory
- [x] Updated the official documentation or not needed
- [x] No breaking changes were made, or a `BREAKING CHANGE: xxx` message
was included in the description
- [x] Added references to related issues and PRs
- [ ] Provided any useful hints for running manual tests
- [ ] Added new benchmarks to [generated
graphs](https://gnoland.github.io/benchmarks), if any. More info
[here](https://github.com/gnolang/gno/blob/master/.benchmarks/README.md).
</details>

---------

Co-authored-by: Morgan <[email protected]>
Co-authored-by: Morgan <[email protected]>
gfanton pushed a commit to moul/gno that referenced this issue Jan 18, 2024
This is a particular case of Go append builtin where the array type is
inferred from the first argument. We detect an untyped const passed as
argument, then we convert it to the array type prior to proceed further.
It fixes further consistency checks and value generation.

Fixes gnolang#1136, fixes gnolang#1149, fixes gnolang#1341.

<!-- please provide a detailed description of the changes made in this
pull request. -->

<details><summary>Contributors' checklist...</summary>

- [x] Added new tests, or not needed, or not feasible
- [x] Provided an example (e.g. screenshot) to aid review or the PR is
self-explanatory
- [x] Updated the official documentation or not needed
- [x] No breaking changes were made, or a `BREAKING CHANGE: xxx` message
was included in the description
- [x] Added references to related issues and PRs
- [ ] Provided any useful hints for running manual tests
- [ ] Added new benchmarks to [generated
graphs](https://gnoland.github.io/benchmarks), if any. More info
[here](https://github.com/gnolang/gno/blob/master/.benchmarks/README.md).
</details>

---------

Co-authored-by: Morgan <[email protected]>
Co-authored-by: Morgan <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working 📦 🤖 gnovm Issues or PRs gnovm related
Projects
Status: 🚀 Needed for Launch
Development

Successfully merging a pull request may close this issue.

3 participants