Skip to content

Use ensure_suffix instead of manually checking for suffixes #15858

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 3 commits into
base: master
Choose a base branch
from

Conversation

MatheusRich
Copy link
Contributor

Follow-up to #15782

This method returns `self` if the string ends with the given suffix. Otherwise, returns a new string with the suffix appended.
This method returns `self` if the string starts with the given prefix. Otherwise, returns a new string with the prefix prepended.
@@ -129,7 +129,7 @@ module Crystal
def each_file_expansion(filename, relative_to, &)
relative_filename = "#{relative_to}/#{filename}"
# Check if .cr file exists.
yield relative_filename.ends_with?(".cr") ? relative_filename : "#{relative_filename}.cr"
yield relative_filename.ensure_suffix(".cr")
Copy link
Member

Choose a reason for hiding this comment

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

Wouldn't this make it so you can't compile the compiler with a previous release?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I might be misunderstanding it, but I'd expect this PR to be merged after #15782 is merged and released.

Copy link
Member

Choose a reason for hiding this comment

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

The compiler is always expected to be built with the same version of the standard library, not the stdlib from the host compiler.
So backward compatibility concerns between src/compiler and src don't matter. They always go together.

@MatheusRich MatheusRich marked this pull request as ready for review June 1, 2025 19:20
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