Add cast and isinstance keywords (#1505)

Finishing support for the type syntax proposed in
https://github.com/bazelbuild/starlark/pull/362

After some reflection, I think we should always parse cast/isinstance as
keywords (requiring 2 arguments, one of which is a value expression and
the other a type expression) since permitting pre-type Starlark syntax
is likely to only lead to confusion, and would be quite difficult to get
right.

Note that this is an **incompatible change**: forms like `cast(x, y, z)`
or `cast = foo` will now be a parse error. However, in practice, I
observe no occurrences of `cast` or `isinstance` used as identifiers in
any Starlark code in Google's monorepo, so I believe that it's rather
unlikely to break anyone.

Store the parsed cast/isinstance exprs as `CallExpr`-s (to avoid
diverging their formatting/walking/etc. support from call expressions)
with an enum field to mark that they are of a special kind.

## Buildtools PR checklist

- [X] The code in this PR is covered by unit/integration tests.
- [X] I have tested these changes and provide testing instructions
below.
- [ ] I have either responded to, or resolved all Gemini comments on the
PR.
- [X] I have read Google Eng Practices on [Small
Changes](https://google.github.io/eng-practices/review/developer/small-cls.html),
this PR either follows these guidelines or the description provides
reasoning for why they can not be followed.
10 files changed
tree: 453207ce6634cbf6034414d675df6996b794b121
  1. .bazelci/
  2. .github/
  3. api_proto/
  4. build/
  5. build_proto/
  6. buildifier/
  7. buildozer/
  8. bzlenv/
  9. config/
  10. convertast/
  11. deps_proto/
  12. differ/
  13. edit/
  14. extra_actions_base_proto/
  15. file/
  16. generatetables/
  17. labels/
  18. lang/
  19. release/
  20. tables/
  21. testutils/
  22. unused_deps/
  23. warn/
  24. wspace/
  25. .bazelrc
  26. .bazelversion
  27. .gitignore
  28. .mailmap
  29. .pre-commit-config.yaml
  30. AGENTS.md
  31. BUILD.bazel
  32. CODEOWNERS
  33. CONTRIBUTING.md
  34. CONTRIBUTORS
  35. go.mod
  36. go.sum
  37. launcher.js
  38. LICENSE
  39. MODULE.bazel
  40. README.md
  41. status.py
  42. update_generated.sh
  43. WARNINGS.md
  44. WORKSPACE
  45. WORKSPACE.bzlmod
README.md

Buildtools for bazel

This repository contains developer tools for working with Google's bazel buildtool.

Build status

Setup

See instructions in each tool's directory.