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

Record Type allows non-defined keys #1046

Open
richardboehme opened this issue Feb 6, 2024 · 2 comments
Open

Record Type allows non-defined keys #1046

richardboehme opened this issue Feb 6, 2024 · 2 comments
Labels
area/core Issues related to the type checker core
Milestone

Comments

@richardboehme
Copy link

When defining a record type, I expected the type checker to complain if an additional (non-defined) key was supplied by the user. Specifically I expected the following to fail type checking:

# @type var x: { name: String }
x = { name: "foo", bar: 'foo' }

Is my assumption wrong or is this a bug in Steep? Might it be related with the change in #256?

Version tested: 1.6.0

@soutaro soutaro added the bug label Feb 6, 2024
@soutaro
Copy link
Owner

soutaro commented Feb 6, 2024

It makes sense. Reporting unknown keys included in literals should help.

@soutaro soutaro added area/core Issues related to the type checker core and removed bug labels Feb 6, 2024
@soutaro soutaro added this to the Steep 1.7 milestone Feb 6, 2024
@ParadoxV5
Copy link
Contributor

ParadoxV5 commented Feb 21, 2024

Comment moved from #256

  • Allows skipping nil-able attributes
# @type var x: { name: String, email: String? }
x = { name: "foo" }                                    # OK 🐕 

Ackchyually nonexistent key is distinguishable from nil values for non-implicit-nil methods such as x.fetch :email.

# @type var x: { name: String, ?email: String? }
x = { name: "foo" }  # OK 💯

P.S. see ruby/rbs#504 regarding ?email:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/core Issues related to the type checker core
Projects
None yet
Development

No branches or pull requests

3 participants