Skip to content

Support (but ignore) type-related syntax #27371

@brandjon

Description

@brandjon

The following pieces of syntax are to be tolerated in Bazel but ignored in the immediate future:

  • Function parameter and return type annotations (def f(x : S) -> T:)
  • Variable type annotations (x : T and x : T = value)
  • type alias declaration statement (type Foo = Bar)
  • Generic type variables in def and type declarations (def f[S, T](x : S, Y: T): and type Foo[T] = Bar[T])
  • Ellipsis token (Tuple[int, ...])
  • Cast operator (cast(list[str], x))

The goal is to permit Bazel 9 to be compatible with .bzls that will use type checking in later versions of Bazel.

For now, any expression is permitted as a type expression, and identifiers in type expressions are not resolved to symbols (so they do not fail when referencing an unknown symbol). In no circumstance is a type expression dynamically evaluated.

In the future when type checking is enabled, invalid type expressions will be rejected. No compatibility guarantee is made for .bzls that use type checking before the type system is non-experimental.

Metadata

Metadata

Assignees

Labels

P1I'll work on this now. (Assignee required)team-Starlark-InterpreterIssues involving the Starlark interpreter used by Bazeltype: feature request

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions