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

Compiler doesn't understand block when using brackets #13975

Open
xendk opened this issue Nov 12, 2023 · 1 comment · May be fixed by #14326
Open

Compiler doesn't understand block when using brackets #13975

xendk opened this issue Nov 12, 2023 · 1 comment · May be fixed by #14326

Comments

@xendk
Copy link
Contributor

xendk commented Nov 12, 2023

(Apologies if this has already been filed, but it's difficult to search for)

The parser does not like block arguments on the var[] syntax. Example:

class Test
  def [](key, &block)
    yield
  end
end

t = Test.new
t["test"] { puts "test" }

Same with do...end. The t.[]("test") { puts "test" } it's sugar for, works fine, but that's pretty ugly in my opinion.

@HertzDevil
Copy link
Contributor

For the record, this works in Ruby

@homonoidian homonoidian linked a pull request Feb 26, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants