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

yield in class body produces two SyntaxError outputs #7370

Closed
headius opened this issue Sep 21, 2022 · 1 comment · Fixed by #7371
Closed

yield in class body produces two SyntaxError outputs #7370

headius opened this issue Sep 21, 2022 · 1 comment · Fixed by #7371
Milestone

Comments

@headius
Copy link
Member

headius commented Sep 21, 2022

It's working, but why do we get two reports?

[] ~/work/jruby $ jruby -e 'class Foo; yield; end'
SyntaxError: -e:1: Invalid yield
SyntaxError: -e:1: Invalid yield

[] ~/work/jruby $ jruby -e 'class Foo; class << self; yield; end; end'
SyntaxError: -e:1: Invalid yield
SyntaxError: -e:1: Invalid yield
@headius headius added this to the JRuby 9.4.0.0 milestone Sep 21, 2022
@headius
Copy link
Member Author

headius commented Sep 21, 2022

Relates to 3.0 feature (#6878):

  • yield in singleton class definitions in methods is now a SyntaxError
    instead of a warning. yield in a class definition outside of a method
    is now a SyntaxError instead of a LocalJumpError. [Feature #15575]

enebo added a commit to enebo/jruby that referenced this issue Sep 21, 2022
Fixes jruby#7370.  We print out twice because main script will try and
precompile and we will raise a syntaxerror (RaiseError) but our
code will blanket catch Exception/Throwable and end up trying
to run the same code through the interpreter.
headius added a commit that referenced this issue Sep 22, 2022
Fixes #7370: yield in class body produces two SyntaxError outputs
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 a pull request may close this issue.

1 participant