Skip to content

cmd/compile: possible oversight with internal/gc.disableExport #31049

@odeke-em

Description

@odeke-em

I was just studying closure.go and noticed that we invoke disableExport(sym) for closures created.
The signature for disableExport says

// disableExport prevents sym from being included in package export
// data. To be effectual, it must be called before declare.

However, in the body of disableExport we see that we invoke sym.SetOnExportList(true)
which toggles the symbol to be exported as per

func (sym *Sym) SetOnExportList(b bool) { sym.flags.set(symOnExportList, b) }

This change is from CL 108216

I believe it should be sym.SetOnExportList(false)
The bug only doesn't show because when creating object files we explicitly check that names are exported as per

if types.IsExported(n.Sym.Name) || initname(n.Sym.Name) {
exportsym(n)
}

otherwise if you add debugs you'll see that we encounter closure symbols such as "".bar.func1

Kindly paging @mdempsky @griesemer

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions