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

Function types with untyped parameter #1806

Merged
merged 3 commits into from
Apr 22, 2024
Merged

Function types with untyped parameter #1806

merged 3 commits into from
Apr 22, 2024

Conversation

soutaro
Copy link
Member

@soutaro soutaro commented Apr 22, 2024

This PR adds untyped function parameters, which means there is no static type checking on parameters/blocks given to method calls and block yields.

class Foo
  def foo: (?) -> void                     # #foo accepts any argument
  def bar: () { (?) -> Integer } -> void   # #bar accepts any block which returns Integer
end

See #1335

@soutaro soutaro added this to the RBS 3.5 milestone Apr 22, 2024
@soutaro soutaro enabled auto-merge April 22, 2024 04:49
@soutaro soutaro added this pull request to the merge queue Apr 22, 2024
@soutaro soutaro changed the title Untyped function Function types with untyped parameter Apr 22, 2024
Merged via the queue into master with commit e2970ca Apr 22, 2024
17 checks passed
@soutaro soutaro deleted the untyped-function branch April 22, 2024 04:58
@ParadoxV5
Copy link
Contributor

The syntax.md update hints that this doesn’t resolve #1622

@soutaro
Copy link
Member Author

soutaro commented Apr 22, 2024

@ParadoxV5 I mean it accepts any blocks too. So (?) -> T is equivalent to (*untyped, **untyped) ?{ (?) -> untyped } -> T from caller side. I think it improves some problems mentioned at #1622.

@ParadoxV5
Copy link
Contributor

Oh, I see. Sorry, it’s late, I’m getting sleepy.

This is the change that confused me:

_proc_ ::= `^` _parameters?_ _self-type-binding?_ _block?_ `->` _type_
         | `^` `(` `?` `)` _self-type-binding?_ _block?_ `->` _type_      # Proc type with untyped parameter

It appears as if (?) doesn’t count the block; but this is the only instance with both (?) and _block?_, so it’s more likely an oversight.

@soutaro
Copy link
Member Author

soutaro commented Apr 22, 2024

Ah... my bad. syntax.md is wrong. 🤦

Correction:

_proc_ ::= `^` _parameters?_ _self-type-binding?_ _block?_ `->` _type_
         | `^` `(` `?` `)` `->` _type_                                   # Proc type with untyped parameter

@soutaro soutaro mentioned this pull request Apr 22, 2024
@soutaro soutaro added the Released PRs already included in the released version label Jun 6, 2024
@ParadoxV5 ParadoxV5 mentioned this pull request Jul 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Released PRs already included in the released version
Development

Successfully merging this pull request may close these issues.

2 participants