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

Returning a ternary if in a method inside a macro yields a syntax error #4488

Closed
spalladino opened this issue May 30, 2017 · 0 comments · Fixed by #4489
Closed

Returning a ternary if in a method inside a macro yields a syntax error #4488

spalladino opened this issue May 30, 2017 · 0 comments · Fixed by #4489
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler

Comments

@spalladino
Copy link
Contributor

In the following code:

record Foo do
  def foo
    return true ? 1 : 2
  end
end

puts Foo.new.foo

The compiler yields:

Syntax error in src/foo.cr:4: 'else' is useless without 'rescue'

Note that if the return keyword is removed (which is optional in this example), the code compiles fine.

Found in Crystal 0.22.0 [3c71228] (2017-04-20) LLVM 3.5.0, on the crystallang/crystal:0.20.0 docker image.

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:compiler
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant