Skip to content

Filetests stop after panic when using nil function argument #4220

Open
@jeronimoalbi

Description

@jeronimoalbi

Filetest breaks when using nil function argument

Description

Filetest break when a public realm function that has a pointer argument receives a nil value and then panics.

This would be a common case when checking that a pointer argument is not nil, normally one would expect public realm functions to panic in such cases.

Your environment

  • Go version (example: go1.24.1)
  • OS and CPU architecture (example: darwin/arm64)
  • Gno commit hash causing the issue (example: 84e53f5)

Steps to reproduce

Create an issue.gno file using snippet:

package issue

func Example(v any) {
	if v == nil {
		// This panic breaks filetests
		panic("boom!")
	}

	// This panic works as expected
	panic("boom!")
}

Create a z_filetest.gno file using snippet:

package main

import "gno.land/r/example/issue"

func main() {
	issue.Example(nil) // Assign nil to break filetest, non nil to pass
}

// Error:
// boom!

Create a gno.mod file using snippet:

module gno.land/r/example/issue

Expected behaviour

Filetest should run and pass.

Actual behaviour

Filetests run breaks.

Logs

=== RUN   file/z_filetest.gno
gno.land/r/example/issue:0: runtime error: invalid memory address or nil pointer dereference (code=2)
FAIL    . 	0.00s
FAIL
FAIL: 0 build errors, 1 test errors

Metadata

Metadata

Assignees

No one assigned

    Labels

    🐞 bugSomething isn't working

    Type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions