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

9k -n does not work with non-local flow control #2435

Closed
enebo opened this issue Jan 6, 2015 · 3 comments
Closed

9k -n does not work with non-local flow control #2435

enebo opened this issue Jan 6, 2015 · 3 comments

Comments

@enebo
Copy link
Member

enebo commented Jan 6, 2015

So we have some outdated exceptions #2416 that need to be removed, but it uncovers some corners in IR that we missed:

jruby -e 'puts "a\nb\nc\n"' | jruby -ne 'break if $_ == "b\n"; puts $_' 

In this case it should print 'a\n' and stop but we actually throw a LocalJumpError:

CFG:
BB [1:LBL_2:0]
BB [2:LBL_3:0]
    %self = recv_self
    line_num(0)
    %v_0 = get_global_var($_)
    %v_1 = call_1o(NORMAL, ==, %v_0, ["b
"]){1O}
    b_false(%v_1, LBL_0:6)
BB [3:LBL_4:4]
    throw(LocalJumpError:break)
BB [4:LBL_0:6]
    %v_1 = get_global_var($_)
    %v_0 = call(FUNCTIONAL, puts, %self, [%v_1])
    return(%v_0)
BB [6:LBL_5:10]
    return(nil)

This is because we treat the code coming in as a ScriptBody and as a script body we know we cannot raise from it. We can either solve this by adding Ruby code to front and back of the supplied script which will mess up backtraces but not require any changes to IR itself OR we will need to accommodate this as a special type of scope.

@enebo enebo added this to the JRuby 9.0.0.0 milestone Jan 6, 2015
@enebo
Copy link
Member Author

enebo commented Jan 6, 2015

Hmm my add ruby to front and back may be ok if we pass into parse with a linuenumber starting at -1 to ignore the first line from syntax errors and backtrace data. @headius also thought maybe this would be while gets; as part of first line of script which would mean we could not need to mess with linenumber. Maybe six of one or not since I don't know if linenumer has special meaning in our parser or not...

@enebo
Copy link
Member Author

enebo commented Jan 6, 2015

oh but the idea is a little more complicated as @headius just pointed out that END and DATA need to be accounted for if we modify the source.

@enebo enebo closed this as completed in bb78f8b Jan 6, 2015
@enebo
Copy link
Member Author

enebo commented Jan 6, 2015

I tested this by running test/jruby/test_command_line_switches.rb which we seem to be no longer regularly running. It is heinously slow but we should contribute a cross-impl version of this to MRI since I can find no tests for -n in it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants