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

Raise proper error at reference with no declared type #60

Closed
wants to merge 1 commit into from

Conversation

nobu
Copy link
Member

@nobu nobu commented Jul 31, 2023

When using reference with no declared type mistakenly, it raise NoMethodError with undefined method `s_value' for nil currently.
Of course it is wrong code, but the message does not seem intentional.

./lib/lrama/grammar/code.rb:77:in `block in translated_user_code'
./lib/lrama/grammar/code.rb:63:in `each'
./lib/lrama/grammar/code.rb:63:in `translated_user_code'
./lib/lrama/grammar/code.rb:14:in `translated_code'
./lib/lrama/grammar/rule.rb:30:in `translated_code'

@nobu
Copy link
Member Author

nobu commented Jul 31, 2023

I'm not sure that this is a right fix; passing rule's name to Lrama::Grammar::Code#translated_user_code feels invasive.

@nobu nobu force-pushed the undeclared-type branch from d7ad271 to 2e0428d Compare July 31, 2023 11:11
When using reference with no declared type mistakenly, it raise
`NoMethodError` with ``undefined method `s_value' for nil`` currently.
Of course it is wrong code, but the message does not seem intentional.

```
./lib/lrama/grammar/code.rb:77:in `block in translated_user_code'
./lib/lrama/grammar/code.rb:63:in `each'
./lib/lrama/grammar/code.rb:63:in `translated_user_code'
./lib/lrama/grammar/code.rb:14:in `translated_code'
./lib/lrama/grammar/rule.rb:30:in `translated_code'
```
@nobu nobu force-pushed the undeclared-type branch from 2e0428d to 66abcc6 Compare July 31, 2023 11:12
@yui-knk
Copy link
Collaborator

yui-knk commented Aug 1, 2023

I created #61. I hope https://github.com/ruby/lrama/pull/61/files#diff-f8748936dd72d99dbcf38b4e4c65325beb000c42d2c1779dd3ca1bcb57bdd0deR1375 covers all cases. Could you check it when you have time?

@nobu
Copy link
Member Author

nobu commented Aug 1, 2023

Close in favor of #61.

@nobu nobu closed this Aug 1, 2023
@nobu nobu deleted the undeclared-type branch August 1, 2023 01:08
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.

2 participants