Skip to content

Rename cstrs to constraints to distinguish from cstrs = constructors #14141

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: trunk
Choose a base branch
from

Conversation

smuenzel
Copy link
Contributor

Currently, the compiler codebase uses cstr for constructor and cstrs for both constraints and constructors.

This is both confusing and makes it difficult to search the code (see below for an example of confusion).
This PR renames any instances of cstrs that refer to constraints to constraints, and leaves any references to constructors alone. The parsetree is not modified, since I gather that this is more complicated.

In typing/typdecl.ml, we have some example where cstrs is used for both constructors and constraints. For example, in the function transl_declaration, we alternate between using cstrs to refer to constraints and constructors.

@smuenzel
Copy link
Contributor Author

See also: #13856 (comment)

@nojb
Copy link
Contributor

nojb commented Jul 12, 2025

This is clearly an improvement to my eyes.

The parsetree is not modified, since I gather that this is more complicated.

My understanding is that nowadays ppxlib and the like should be able to handle renaming a label.

@smuenzel
Copy link
Contributor Author

Nice, I've modified the parsetree as well. I will try to find any other instances and then mark the PR as ready for review

@smuenzel smuenzel marked this pull request as ready for review July 12, 2025 08:04
@gasche
Copy link
Member

gasche commented Jul 12, 2025

This is clearly an improvement in my eyes.

And here I thought that @nojb had transcended to a higher plane of existence where variable naming does not matter anymore...

I agree this is a clear improvement.

Copy link
Contributor

@nojb nojb left a comment

Choose a reason for hiding this comment

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

LGTM

@nojb nojb added parsetree-change Track changes to the parsetree for that affects ppxs no-change-entry-needed and removed no-change-entry-needed labels Jul 12, 2025
@nojb
Copy link
Contributor

nojb commented Jul 12, 2025

(The CI failure seems unrelated to the changes here.)

@smuenzel
Copy link
Contributor Author

Should we merge this one?

@nojb
Copy link
Contributor

nojb commented Jul 18, 2025

Yes, as soon as the CI passes.

@nojb nojb added the merge-me label Jul 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge-me parsetree-change Track changes to the parsetree for that affects ppxs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants