Syntax error in tester.cr:1: unterminated parenthesized expression
def foo(x : String) : Tuple (String, String)
^
This is, hopefully obviously, _not_ an "unterminated parenthesized expression". The parentheses are very much terminated. The consequences of this error are wasting time trying to find a missing ) that isn't missing.
If you remove the space between Tuple and the parens after it the error goes away.
Sample code here
def foo(x : String) : Tuple (String, String)
{x, x}
end
Tested with
Crystal 0.24.2 (2018-03-10)
LLVM: 5.0.1
Default target: x86_64-apple-macosx
I'm not sure this is a bug or whether it's worth fixing. This is valid syntax:
def foo : Int32 1 end
After a return type, the only thing that can come (apart from forall) is the method's body. So in your case, after Tuple (after the space) comes the body, which gives you the same syntax error as this:
(String, String)
And that isn't valid Crystal.
Should def foo : Int32 1 end be valid Crystal? IMHO it looks a bit confusing and I don't know if avoiding a line break adds any value. Why not require a line break (or ;) between the method's signature and body?
Sure, PRs are welcome.
Most helpful comment
Should
def foo : Int32 1 endbe valid Crystal? IMHO it looks a bit confusing and I don't know if avoiding a line break adds any value. Why not require a line break (or;) between the method's signature and body?