Skip to content
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

Add missing require in iterator_spec #11148

Merged
merged 1 commit into from
Aug 28, 2021

Conversation

asterite
Copy link
Member

Without it, the spec can't be run standalone.

Without it, the spec can't be run standalone.
@asterite asterite added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib:specs labels Aug 27, 2021
@Fryguy
Copy link
Contributor

Fryguy commented Aug 27, 2021

Aside, I've had this problem in my personal code, and I'm wondering if there's a way for the compiler to catch this? I can't think of a way, personally, but it would be extremely useful if these kinds of things just failed up front.

@asterite
Copy link
Member Author

Yes: specify at the top of each file the requires/imports needed for the file to type-check. That is, make it more similar to JS and Python, and not like Ruby. But of course that's a huge change to the language, and it brings a lot of verboseness.

@Fryguy
Copy link
Contributor

Fryguy commented Aug 27, 2021

Right, exactly - I can't see how it can be done without a deeper language level change. It happens so infrequently, and the fix is usually so simple, so it seems not worth it.

@beta-ziliani beta-ziliani added this to the 1.2.0 milestone Aug 27, 2021
@straight-shoota
Copy link
Member

This concrete practical problem mostly matters for files that can be used as entry points of a program. This is common for spec files, but apart from that, it's very rare (and other entry points are usually well tested).

You could run something like this to check if each spec file compiles on its own:

find spec -name '*_spec.cr' -exec crystal spec {} \;

@asterite asterite merged commit 959bbef into master Aug 28, 2021
@asterite asterite deleted the bug/iterator-spec-missing-require branch August 28, 2021 09:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib:specs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants