Syntax error with "do"-block in Local scope
Reported by Wes Oldenbeuving | November 30th, 2008 @ 12:23 PM
The following code works:
[1,2,3].each do |n|
puts(n.to_s())
But this fails:
[1,2,3].each do |n|
puts(n.to_s())
puts("Now it dies")
The following stacktrace is returned:
exception: {exception,
{throw,
{tuple,
{error,
{tuple,
{4,
{list,{[],"syntax error before: puts"}}}}}}}}
stacktrace: [{'Eval',string,1},
{'Loader',eval_input,1},
{init,start_it,1},
{init,start_em,1}]
Defining the do-block code in ire works, as does defining the same functionality with a curly braces block:
[1,2,3].each { |n| puts(n.to_s()) }
puts("Now it lives")
The code samples can also be found at: http://gist.github.com/30494
It looks to me as if the do-block is somehow not properly closed when parsed from a file in the Local scope. This explains why it does work when it is the last thing in the file or in ire. The fact that it works when the code is defined as a method in a class is puzzling.
No comments found
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป
Reia a dynamic scripting language for the Erlang virtual machine (BEAM)