Skip to content

rf: Add support for removing list items#49

Merged
rsc merged 1 commit intorsc:mainfrom
jitsu-net:enhance-rm
Oct 29, 2025
Merged

rf: Add support for removing list items#49
rsc merged 1 commit intorsc:mainfrom
jitsu-net:enhance-rm

Conversation

@jitsu-net
Copy link
Copy Markdown
Collaborator

This commit adds support for removing items within a list, most notably function parameters.

Comment thread rm.go Outdated
}
switch idx := find(obj, n.Names); {
case idx < 0:
snap.ErrorAt(obj.Pos(), "cannot delete declaration of %s (more than 1 field)", obj.Name())
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Isn't this case 'unknown field'?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done.

Comment thread rm.go Outdated
}
switch idx := find(n, fl); {
case idx < 0:
snap.ErrorAt(obj.Pos(), "cannot delete declaration of %s", obj.Name())
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Whatever the error is, this one should match.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done.

Comment thread rm.go Outdated
case idx == 0:
start := n.Names[idx].Pos()
end := n.Names[idx+1].Pos() - 1 // delete trailing comma
// start, end := nodeRange(snap, n.Names[idx])
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Delete old code.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done.

Comment thread rm.go Outdated
}
switch idx := find(obj, n.Names); {
case idx < 0:
snap.ErrorAt(obj.Pos(), "cannot delete declaration of %s (more than 1 field)", obj.Name())
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

"more than 1 field" seems like the wrong error message now.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done.

Copy link
Copy Markdown

@dr2chase dr2chase left a comment

Choose a reason for hiding this comment

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

I have no idea how to operate this review tool, but this overall LGTM.

This commit adds support for removing items within a list, most
notably function parameters.
@rsc rsc merged commit 7d6b91d into rsc:main Oct 29, 2025
1 check passed
@jitsu-net jitsu-net deleted the enhance-rm branch October 29, 2025 17:12
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.

3 participants