Skip to content

daemon: work around go1.21 compiler bug#47020

Merged
cpuguy83 merged 1 commit intomoby:masterfrom
thaJeztah:fix_go_compilerbug
Jan 4, 2024
Merged

daemon: work around go1.21 compiler bug#47020
cpuguy83 merged 1 commit intomoby:masterfrom
thaJeztah:fix_go_compilerbug

Conversation

@thaJeztah
Copy link
Copy Markdown
Member

The Go 1.21.5 compiler has a bug: per-file language version override directives do not take effect when instantiating generic functions which have certain nontrivial type constraints. Consequently, a module-mode project with Moby as a dependency may fail to compile when the compiler incorrectly applies go1.16 semantics to the generic function call.

As the offending function is trivial and is only used in one place, work around the issue by converting it to a concretely-typed function.

- What I did

- How I did it

- How to verify it

- Description for the changelog

- A picture of a cute animal (not mandatory but encouraged)

The Go 1.21.5 compiler has a bug: per-file language version override
directives do not take effect when instantiating generic functions which
have certain nontrivial type constraints. Consequently, a module-mode
project with Moby as a dependency may fail to compile when the compiler
incorrectly applies go1.16 semantics to the generic function call.

As the offending function is trivial and is only used in one place, work
around the issue by converting it to a concretely-typed function.

Signed-off-by: Cory Snider <[email protected]>
@thaJeztah thaJeztah added this to the 25.0.0 milestone Jan 3, 2024
Copy link
Copy Markdown
Member Author

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"LGTM" (I opened the PR, but commit was by @corhere

@thaJeztah thaJeztah requested a review from corhere January 3, 2024 23:05
Copy link
Copy Markdown
Contributor

@corhere corhere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I can review my own commit if you insist

@thaJeztah
Copy link
Copy Markdown
Member Author

hehe, yeah, needed a green check 😉

@thaJeztah thaJeztah self-assigned this Jan 3, 2024
@cpuguy83 cpuguy83 merged commit e2b78f0 into moby:master Jan 4, 2024
@thaJeztah thaJeztah deleted the fix_go_compilerbug branch January 4, 2024 00:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants