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

Untyped block args #1335

Closed
soutaro opened this issue May 16, 2023 · 2 comments
Closed

Untyped block args #1335

soutaro opened this issue May 16, 2023 · 2 comments
Labels
enhancement New feature or request Released PRs already included in the released version
Milestone

Comments

@soutaro
Copy link
Member

soutaro commented May 16, 2023

AR::Base.scope accepts lambdas, but the type of the lambdas is difficult to describe in RBS.

class AR::Base
  def self.scope: (Symbol, ^(*untyped, **untyped) -> void) -> void
end

The proc type means it can receive any argument and any keywords, while what we want is a proc is required but the type of its arguments is not checked. So, we want to introduce a new syntax for untyped args.

Possible syntax:

class AR::Base
  # ...
  def self.scope: (Symbol, ^(...) -> void) -> void
                | (Symbol) { (...) -> void } -> void

  # ?
  def self.scope: (Symbol, ^(?) -> void) -> void
                | (Symbol) { (?) -> void } -> void

  # untyped
  def self.scope: (Symbol, ^untyped -> void) -> void
                | (Symbol) { untyped -> void } -> void
end

Any other ones?

@soutaro soutaro added the enhancement New feature or request label May 16, 2023
@soutaro soutaro added this to the RBS 3.2 milestone May 16, 2023
@ParadoxV5
Copy link
Contributor

Can simply use Proc for lambdas; this new syntax mainly benefits untyped blocks

untyped -> void

This suggestion is uncomfortably similar to (untyped) -> void. In fact, it conflicts with the possibility of making arguments’ round parentheses optional (if there’s such a possibility).

@soutaro
Copy link
Member Author

soutaro commented Jun 6, 2023

I'm going to implement it in (?) -> void syntax. ... would be confusing because Ruby has similar syntax with totally different semantics. untyped -> void is too similar to normal positional argument.

@soutaro soutaro modified the milestones: RBS 3.2, RBS 3.3 Aug 17, 2023
@soutaro soutaro modified the milestones: RBS 3.3, RBS 3.4 Nov 21, 2023
@soutaro soutaro modified the milestones: RBS 3.4, RBS 3.5 Dec 14, 2023
@soutaro soutaro closed this as completed Jun 5, 2024
@soutaro soutaro added the Released PRs already included in the released version label Jun 6, 2024
@soutaro soutaro mentioned this issue Jul 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Released PRs already included in the released version
Development

No branches or pull requests

2 participants