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

Regression in 1.7.0: Parser rejects valid class def syntax with whitespace after class name #12974

Closed
toddsundsted opened this issue Jan 18, 2023 · 8 comments · Fixed by #12977
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. kind:regression Something that used to correctly work but no longer works topic:compiler:parser
Milestone

Comments

@toddsundsted
Copy link
Contributor

Bug Report

I didn't see this called out in the changelog or previous issues as an intentional change, so I'm raising it as a possible compiler regression.

The following code compiles in versions of the compiler up to 1.6.2:

module Foo end
class Bar include Foo end

It no longer compiles in 1.7.x. The following does compile, as expected:

module Foo end
class Bar
  include Foo
end
@toddsundsted toddsundsted added the kind:bug A bug in the code. Does not apply to documentation, specs, etc. label Jan 18, 2023
@Blacksmoke16
Copy link
Member

Caused via #12622. Which was listed as a breaking change, but still might be a regression in this particular case.

Also I didn't realize you could have inlined declarations like that without using ;.

@Blacksmoke16 Blacksmoke16 added topic:compiler:parser kind:regression Something that used to correctly work but no longer works labels Jan 18, 2023
@asterite
Copy link
Member

I think we should fix it. It works in Ruby just fine and I see no reason to disallow such syntax.

@straight-shoota straight-shoota added this to the 1.7.2 milestone Jan 18, 2023
@straight-shoota
Copy link
Member

straight-shoota commented Jan 18, 2023

Yeah, that breaking is not acceptable.

We should probably just revert #12622 and then figure out what we can salvage from it.

@Sija
Copy link
Contributor

Sija commented Jan 18, 2023

IMO such a breaking change is better than the syntax with even more exceptions.

@asterite
Copy link
Member

The thing is that there were no exceptions before. And none was needed. class Foo include Bar end was fine. class Foo:bar end also kind of works: it's a class name followed by a symbol. It works in Ruby too. It doesn't look good, but it makes sense from a lexer/parser perspective. We wanted to fix that (the Foo:bar thing which looks strange) and with it we broke something else.

@straight-shoota
Copy link
Member

straight-shoota commented Jan 18, 2023

@Sija If it breaks working code, it's never better. In some cases it can be unavoidable to fix serious bugs.

But in this case, it's completely avoidable.

That doesn't mean that the changes from #12622 are undesired. But they're not necessary. We can postpone them, tinker with it and decide what syntax should be accepted and what not. We were expecting this to only affect obscure edge cases that are never used. No big deal. But apparently it affects real code, and that we should prevent.

@toddsundsted
Copy link
Contributor Author

thank you, all!

@straight-shoota
Copy link
Member

Resolved by #12977

@straight-shoota straight-shoota changed the title Possible Compiler Regression in 1.7.x Regression in 1.7.0: Parser rejects valid class def syntax with whitespace after class name Jan 23, 2023
toddsundsted added a commit to toddsundsted/ktistec that referenced this issue Jan 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. kind:regression Something that used to correctly work but no longer works topic:compiler:parser
Projects
None yet
5 participants