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

Rescue doesn't accept global type path #2593

Merged
merged 1 commit into from
May 17, 2016

Conversation

mosop
Copy link
Contributor

@mosop mosop commented May 14, 2016

This code occurs a compiler's error because the parser doesn't accept global type paths at rescue:

begin
  # ...
rescue ::Foo
  # ...
end

I quickly fixed the corresponding source code, but it may be not perfect. In addition, my code doesn't consider Underscore nodes like:

begin
  # ...
rescue _ # occurs an error 
  # ...
end
begin
  # ...
rescue ex : _ # occurs an error, too
  # ...
end

Thank you.

@asterite
Copy link
Member

@mosop Thank you! The code is perfect except for one bit: don't use %i(...), as it creates a new array each time code reaches that point. Better switch on the token's type. Maybe there's another overload for check that accepts many symbols.Or otherwise move the array to a constant (this is done in some places in the parser), but I think a simple if/elsif or case/when is enough here.

@mosop mosop closed this May 15, 2016
@mosop mosop force-pushed the rescue_accepts_global_type_path branch from 4532688 to 2267a28 Compare May 15, 2016 04:34
@mosop
Copy link
Contributor Author

mosop commented May 15, 2016

@asterite Hi. I changed the local array into a constant. I understand your preferred way, a simple if/elsif or case/when, but I think it may need a little more complex implementation and maybe additional test specs for message formatting. Thank you.

@mosop mosop reopened this May 15, 2016
@asterite
Copy link
Member

@mosop Don't worry, the fix is already perfect, I'll take care of the formatter.

Thank you! ❤️

@asterite asterite merged commit b33100b into crystal-lang:master May 17, 2016
@mosop mosop deleted the rescue_accepts_global_type_path branch May 19, 2016 03:22
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.

None yet

2 participants