-
Notifications
You must be signed in to change notification settings - Fork 169
Union types #315
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
base: starlark-with-types
Are you sure you want to change the base?
Union types #315
Conversation
This is a top type. Previously it was omitted in the design, but it is needed to correctly type methods in the builtin method library.
### Unions | ||
|
||
Some functions may accept parameters of multiple types. In this | ||
case parameter is annotated with a union type `A|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.
nit: the parameter
Some functions may accept parameters of multiple types. In this | ||
case parameter is annotated with a union type `A|B`. | ||
|
||
User functions are limited to optional types, that is `None|A`, |
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.
Nit: "user functions" might be ambiguous between application-defined vs starlark-programmer-defined. Maybe "Starlark-defined functions"? Not sure whether there's precedent terminology elsewhere in this spec.
@@ -3333,6 +3350,8 @@ See https://github.com/bazelbuild/starlark/issues/47. | |||
|
|||
### float | |||
|
|||
`float(x: str|bool|int|float, /) -> float` |
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.
(No action needed for this PR) There may be a bunch of other args to other builtins that are Noneable, in the sense that we take None
as an alternative to omitting the parameter entirely.
No description provided.