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

calling #each on obj typed with record yields |bot, bot| types #1888

Open
HoneyryderChuck opened this issue Jun 12, 2024 · 3 comments
Open

Comments

@HoneyryderChuck
Copy link
Contributor

# RBS
# type rec = {foo: String, bar: Integer }

# and having variable a typed as rec

a.each do |x, y|
# x and y appear as bot

I'm also assuming narrowing on key won't also work (but that's more of a feature request perhaps):

a.each do |x, y|

if x == :foo 
  # then y is a string
@soutaro
Copy link
Member

soutaro commented Jun 13, 2024

Looks like it works with Steep 1.7.1. Can you give me some more detail to reproduce?

スクリーンショット 2024-06-13 17 38 01

@HoneyryderChuck
Copy link
Contributor Author

HoneyryderChuck commented Jun 14, 2024

module A
  type context = {
    ?msg: Hash[interned, untyped],
    # identifiers
    ?identifiers: Hash[interned, untyped],
    # ....
  }

  def self?.hash_flat_merge: (context, context) -> context
}

Then "#each" declares them as bot in steep.

Captura de ecrã 2024-06-14, às 15 55 51

using latest rbs and steep.

@soutaro
Copy link
Member

soutaro commented Jun 14, 2024

💡 Optional keys are not supported and simply ignored in Steep. The implementation in RBS was finished, but the Steep side slipped my mind. 🙇

@sampersand You may be interested in working for this.

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

No branches or pull requests

2 participants