Skip to content

vlib: use defer(fn) { syntax where appropriate#25653

Merged
spytheman merged 10 commits into
vlang:masterfrom
StunxFS:vlib/use-new-defer-syntax
Nov 4, 2025
Merged

vlib: use defer(fn) { syntax where appropriate#25653
spytheman merged 10 commits into
vlang:masterfrom
StunxFS:vlib/use-new-defer-syntax

Conversation

@StunxFS

@StunxFS StunxFS commented Nov 3, 2025

Copy link
Copy Markdown
Contributor

Continuation of PR #25639.
Merge after PR #25651.

This PR makes use of the syntax defer(fn) { where appropriate.

v -scoped-defer -o v cmd/v works!

@StunxFS StunxFS changed the title vlib: use defer(en) { syntax where appropriate vlib: use defer(fn) { syntax where appropriate Nov 3, 2025
mut res := 0
$if trace_ssl ? {
defer {
defer(fn) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why does this need to be changed?
Because it is inside a the comptime $if scope, or for some other reason?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Exactly, defer uses the comptime $if scope, in a future PR I will make defer use the parent scope instead of that one.

Comment thread examples/readline/readline.v Outdated
Comment thread vlib/net/websocket/websocket_client.v Outdated
Comment thread vlib/os/asset/asset.v Outdated

@spytheman spytheman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Excellent work.

@spytheman spytheman merged commit 82cd44e into vlang:master Nov 4, 2025
91 of 92 checks passed
@StunxFS StunxFS deleted the vlib/use-new-defer-syntax branch November 4, 2025 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants