Skip to content

🐞 Module constructor returns pointer for empty object instead of returning nil for *Directory type #6252

@aweris

Description

@aweris

What is the issue?

When I created a module constructor with // +optional=true missing flag returned a pointer of the empty object instead of nil.

Example Code:

package main

func New(
	// +optional=true
	src *Directory,
) *A {
	return &A{Src: src}
}

type A struct {
	Src *Directory
}

func (m *A) IsEmpty() bool {
	return m.Src == nil
}

Log output

dagger call is-empty
✔ dagger call is-empty [1.38s]
┃ false
• Cloud URL: https://dagger.cloud/runs/6ed9327f-a4e3-4257-9864-87733b642a5f
• Engine: 64fae4326b32 (version v0.9.4)
⧗ 2.79s ✔ 31 ∅ 7

Steps to reproduce

The code from example can be used for reproducing the issue.

SDK version

GO SDK v0.9.4

OS version

macOS 14.0

cc: @jedevc

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions