-
Notifications
You must be signed in to change notification settings - Fork 90
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
Leverage function contract information #1888
Conversation
= fun src => | ||
{ | ||
# TODO: we shouldn't need to type the first letter to get completion. | ||
some_val = src.foo.b |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realized that for some reason, the completion doesn't fire if we don't start to typing a prefix of an existing field, while this doesn't happen for other kind of completion (for type-based completion for example, if you start to type std.
, you get a list of all available functions - same for a record literal, if you define record = {...}
and then later type record.
, you get a full list - but here we get nothing until we type the first letter of a field). I'll open a separate issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fact it's the good old NLS can't handle some incomplete inputs. If I add an identifier at the end of this line, something like src_val = src.foo. dummy_value
, which is then parsed correctly (because right now you can have a space between fields and the .
character, for the best or the worst), then you get completion.
00c4173
to
bff01a5
Compare
When a function is annotated with a function contract, use this additional type information to enable completion in the LSP (and also use the domain as the type of the function's argument in the typing environment, even if we are in walk mode). Contract data are easy to fetch during typechecking when available and use them improve the developer experience by bringing in more static information.
bff01a5
to
8681846
Compare
Closes #1885.
When a function is annotated with a function contract, use this additional type information to enable completion in the LSP (and also use the domain as the type of the function's argument in the typing environment, even if we are in walk mode). Contract data are easy to fetch during typechecking when available and use them improve the developer experience by bringing in more static information.
I hesitated to updated the documentation about the fact that the typechecker is marginally smarter about function contracts, but I'm not sure yet we want to commit to it fully yet. Honestly I don't expect it to be used a lot in the wild, I mostly did it because it was virtually free (performance-wise and code complexity-wise).