Skip to content

[rbs/unit_test] Treat nil as a return value#2257

Merged
soutaro merged 9 commits intoruby:masterfrom
ksss:test-return-nil
Jan 28, 2025
Merged

[rbs/unit_test] Treat nil as a return value#2257
soutaro merged 9 commits intoruby:masterfrom
ksss:test-return-nil

Conversation

@ksss
Copy link
Collaborator

@ksss ksss commented Jan 26, 2025

On the Ruby side, when nil is returned, rbs/unit_test interprets it as a break, which revealed that the return value was not being checked.
I have fixed this issue and also fixed the tests that depended on this issue.

ksss added 8 commits January 25, 2025 23:57
`%a{implicitly-returns-nil}` cannot be checked to return `nil`
```
'\u{e4 f6 fc}'.encode('ISO-8859-1').to_sym.casecmp?(:'\u{c4 d6 dc}')
=> false
```
```
map.getkey(123)
=> nil
```
Since the return values of some methods have changed, we use gem to fix the behavior.
@ksss ksss changed the title Treat nil as a return value [rbs/unit_test] Treat nil as a return value Jan 27, 2025
@ksss
Copy link
Collaborator Author

ksss commented Jan 27, 2025

I made changes to RBS::Test::TypeCheck to account for %a{implicitly-returns-nil}.
Specifically, I updated it to allow annotations to be passed as arguments.

Copy link
Member

@soutaro soutaro left a comment

Choose a reason for hiding this comment

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

Thanks! 🙏

@soutaro soutaro added this pull request to the merge queue Jan 28, 2025
@soutaro soutaro added this to the RBS 3.9 milestone Jan 28, 2025
Merged via the queue into ruby:master with commit 964066e Jan 28, 2025
19 checks passed
@soutaro soutaro added the Released PRs already included in the released version label Mar 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Released PRs already included in the released version

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants