Skip to content

'break' in method context should emit a parse SyntaxError #4990

Description

@enebo

'break' in method context should emit a parse SyntaxError. We will parse it and then throw a LocalJumpError if we ever run into it.

def foo
  if false
    break
  end
end

foo

The severity is very minor since most people will not write code like this unless they are JRuby-only, but it should not be difficult to track down since it happens during parse time at some point (we just need to find the error message in MRIs source).

Activity

  1. added this to the Invalid or Duplicate milestone on Apr 5, 2026
  2. enebo commented on Apr 5, 2026

    @enebo
    MemberAuthor

    In reviewing issues I realize this is working as expected in that we lazily build methods and the building is where the syntax error ends up occuring. As this only affects legacy parser and will not affect prism (which supplies all parse errors including this one) this will not be an issue once we are full time on prism.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions