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

Better/clearer error for when trying to dot-access a field of a record that's optional #7148

Open
zth opened this issue Nov 7, 2024 · 0 comments

Comments

@zth
Copy link
Collaborator

zth commented Nov 7, 2024

type user = {name: string}

let user = Some({name: "Tests"})

let name = user.name

This leads to some variation of this error:

This has type: option<user>
  But it's expected to have type: user

But, it would be much better if we could tell the user that "hey, you're trying to dot access a field of a record, but the thing you're dot accessing on is actually an option, so you need to unwrap it somehow first".

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

No branches or pull requests

1 participant