)]}'
{
  "commit": "d71268cdd1f991b215cd8ec218d49000e4c2bf16",
  "tree": "10fa3be3bc46b42420e7bef1a8e1e5495fa870ac",
  "parents": [
    "e2023945a6e6673168e1bfeeec95007ae21e66d1"
  ],
  "author": {
    "name": "Fabian Meumertzheim",
    "email": "fabian@meumertzhe.im",
    "time": "Thu Aug 06 14:01:40 2026 -0700"
  },
  "committer": {
    "name": "GitHub",
    "email": "noreply@github.com",
    "time": "Thu Aug 06 21:01:40 2026 +0000"
  },
  "message": "[8.8.0] Accept and ignore Bazel 10 Starlark type syntax (#30373)\n\n### Description\n\nBackports the Bazel 10 Starlark type syntax parser to the 8.x line in\n\"accept but ignore\" mode: `.bzl` files using type annotations, type\naliases, generic `def` parameters, `...`, `cast()`, and `isinstance()`\nnow load successfully, with all type information ignored. This matches\nmaster\u0027s default behavior (`--experimental_starlark_type_syntax`\ndefaults to true, type checking off ⇒ annotations are parsed tolerantly\nas arbitrary expressions and never resolved).\n\nWithout this PR, 8.8.0 fails to load even the most basic annotated file\nwith a syntax error:\n\n```starlark\ndef f(x: list[str]):  # syntax error at \u0027:\u0027: type annotations are disallowed\n    pass\n```\n\nThe following commits are cherry-picked, in order:\n\n* 299e903710 Extend syntax with parameter type annotations\n* 2dbda274cd Use type specific productions\n* d1c3727795 Extend syntax with return types\n* ab034aea73 Implement --experimental_starlark_types* flags\n* fb7ca12439 Implement TypeApplication and fix NodePrinter\n* aa61fc8a8d Allow empty type arguments for type applications (parser\nsupport only)\n* 0b615ff55e Introduce Expression.parseTypeExpression() (parser support\nonly)\n* f60a22e8ef Allow parsing arbitrary uninterpreted Starlark type\nexpressions\n* f3653ca8ae Allow parsing type alias statements\n* 88678c00c4 Allow parsing generic type parameters in `def` statements\n* 96d2f60fb9 Allow parsing `cast` expressions (and evaluating them as\nthe value argument)\n* 664e87b594 Evaluate type alias statements as a no-op\n* 5c8655ca1f Add variable type annotation syntax and resolver behavior\n* 2390ce6760 Add Ellipsis token and node\n* 515083c24a Add `isinstance` keyword, and allow isinstance(x,t) to be\nparsed - but not resolved\n* 44665ecd71 Properly gate dynamic type checking with flag (syntax\ntolerance only)\n* f38f0e448a Disallow type syntax in .scl files\n* f1b3273f9f, 2004bad12f, f0011d8f29 (the three parser-only slices from\n#30092: `tuple[T, ...]`, `tuple[()]`, struct type)\n\n### How to review\n\nEvery commit keeps its original `Change-Id`, so the deviation of each\ncherry-pick from its master original can be computed mechanically with\n`git range-diff` (checking out this PR as `\u003cpr-head\u003e`):\n\n```sh\ngit log --reverse --format\u003d%H origin/release-8.8.0..\u003cpr-head\u003e | while read pick; do\n  cid\u003d$(git log -1 --format\u003d%B $pick | sed -n \u0027s/^Change-Id: //p\u0027 | head -1)\n  orig\u003d$(git log --format\u003d%H --grep\u003d\"Change-Id: $cid\" origin/master | tail -1)\n  git range-diff --creation-factor\u003d100 $orig^! $pick^!\ndone\n```\n\nOnly the lines range-diff marks as changed between the two patches need\nhuman review; everything else is upstream code verbatim. Running this\ntoday gives the following review-effort map (changed diff lines per\ncommit): all commits are at or below 22 except 0b615ff55e (99),\nf60a22e8ef (51), 664e87b594 (44), 5c8655ca1f (267), 44665ecd71 (133),\nand f38f0e448a (91) — which are exactly the sliced/adapted commits\nexplained below. For the last three commits, substitute the\nalready-sliced commits from #30092 (1681dfb115, b172b104c3, 745ec85067)\nas the range-diff baseline instead of the master originals; against that\nbaseline they deviate by 2, 12, and 2 lines respectively.\n\nEach commit is best reviewed against its master original (referenced by\n`PiperOrigin-RevId`/`Change-Id` in the message). Everything not listed\nbelow is verbatim upstream code; in particular, the type grammar in\n`Parser.java` (all `parseType*` productions, type aliases, generics,\n`cast`/`isinstance`) and the new AST node files `TypeAliasStatement`,\n`TypeApplication`, `Ellipsis`, and `IsInstanceExpression` are\nbyte-identical to current master.\n\nNon-trivial deviations from master, grouped by cause:\n\n**1. The type checking machinery is intentionally not backported**\n(~4,800 lines on master: `StarlarkType`, `Types`, `TypeChecker`,\n`TypeTagger`, `TypeResolver`, and the dynamic checks in\n`Eval`/`StarlarkFunction`):\n\n* 0b615ff55e is taken without the static `Resolver.resolveType()` (it\nneeds the types package).\n* 44665ecd71 is reduced to its\n`FileOptions`/`Parser`/flag/`BzlCompileFunction` hunks; the\n`Eval`/`StarlarkFunction` dynamic-check gating hunks are dropped. The\n`StarlarkSemantics.EXPERIMENTAL_STARLARK_TYPE_CHECKING` key constant is\nadded by hand since `BzlCompileFunction` still needs it.\n* `CastExpression` lacks master\u0027s `starlarkType` field/getter/setter\n(the type-tagging slot, only written by `TypeTagger`).\n* Hunks touching checker test files\n(`TypeCheckTest`/`DynamicTypeCheckTest`, the syntax-package\n`StarlarkTypesTest`) are dropped wherever a commit touched them.\n* Net effect: `--experimental_starlark_type_checking` (default off) on\n8.x only switches annotations from tolerant to structured parsing; it\nperforms no type checking.\n\n**2. The doc-comments feature (03921eded1) is not backported**, so its\nthreading is stripped from 5c8655ca1f\u0027s hunks:\n\n* `AssignmentStatement` and `VarStatement` have no `docComments`\nfield/getter; their constructors take one fewer parameter.\n* `Parser#parseAssignment` does not call `maybeParseTrailingDocComment`\n(method not introduced), and `Expression#parseExpression` does not skip\n`DOC_COMMENT_*` tokens.\n* `Resolver#bind` is `bind(id, isLoad, hasType)` instead of master\u0027s\nfour-parameter form; `createBindingsForLHS` takes no doc-comments\nparameter.\n\n**3. `Binding.isSyntactic` does not exist on 8.x.** In the\none-annotation-per-declaration check inside `Resolver#bind`, master\u0027s\n`bind.isSyntactic` is replaced by `bind.first !\u003d null` (on 8.x,\n`Binding#first` is documented as \"first binding use, if syntactic\", so\nthe two are equivalent).\n\n**4. Older test scaffolding on 8.x:**\n\n* `EvaluationTestCase` gains `setFileOptions`/`getFileOptions` (ported\nfrom master, folded into the 664e87b594 pick) because the cherry-picked\n`EvaluationTest` cases need them.\n* In `ParserTest`/`NodePrinterTest`/`ResolverTest`, only each commit\u0027s\nown payload tests are taken where the surrounding context consists of\nmaster-only tests that don\u0027t exist on 8.x; two `NodePrinterTest`\nassertions stay in 8.x\u0027s `join(...)` style.\n\n**5. The `parseExpression` → `parseExpr` rename** from f60a22e8ef is\napplied in full so the parser stays textually close to master.\n\n### Verification\n\n`//src/test/java/net/starlark/java/...` and\n`//src/test/java/com/google/devtools/build/lib/starlark:StarlarkTypesTest`\npass. Additionally verified end-to-end: a workspace exercising unknown\ntype names, providers as types, `list[str]`, `tuple[int, ...]`,\n`tuple[()]`, `struct[{\"a\": int}]`, parameterized type aliases, variable\nannotations, string-literal types, and runtime `cast()` passthrough\nloads identically (default flags) with a Bazel built from this branch\nand one built from master, and annotated module-level assignments\nexecute correctly.\n\n### Motivation\n\nForward compatibility for the 8.x LTS line: once rulesets start adopting\nBazel 10 type annotations, users on Bazel 8 must still be able to load\nthose rulesets. This is the 8.x counterpart of the tolerance work that\nalready landed for 9.0.0 (#27760, #27838, #28069) and is pending for\n9.3.0 (#30092).\n\n### Build API Changes\n\nYes: this extends the accepted `.bzl` grammar and adds the experimental\nflags `--experimental_starlark_type_syntax` (default true),\n`--experimental_starlark_types_allowed_paths`, and\n`--experimental_starlark_type_checking` (default false) to 8.x. Part of\nthe Starlark types effort (#27370). The change is purely additive and\nbackward compatible: previously invalid syntax now parses and is\nignored; `.scl` files continue to reject type syntax.\n\n### Checklist\n\n- [x] I have added tests for the new use cases (if any).\n- [ ] I have updated the documentation (if applicable).\n\n### Release Notes\n\nRELNOTES: Bazel now parses and ignores the Starlark type annotation\nsyntax introduced by newer Bazel versions (gated by\n`--experimental_starlark_type_syntax`, enabled by default).\n\n---------\n\nCo-authored-by: Googler \u003cilist@google.com\u003e\nCo-authored-by: arostovtsev \u003carostovtsev@google.com\u003e\nCo-authored-by: brandjon \u003cbrandjon@google.com\u003e\nCo-authored-by: Ian (Hee) Cha \u003cheec@google.com\u003e",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "6f41b5475e23fce5d1a8afea2880d0c4e8d80b63",
      "old_mode": 33188,
      "old_path": "src/main/java/com/google/devtools/build/lib/packages/semantics/BuildLanguageOptions.java",
      "new_id": "96994370d7191b96f2fa1f96caa49a00017697af",
      "new_mode": 33188,
      "new_path": "src/main/java/com/google/devtools/build/lib/packages/semantics/BuildLanguageOptions.java"
    },
    {
      "type": "modify",
      "old_id": "f550e1ca5ed85e2d88aa8d51e688c922115a3b43",
      "old_mode": 33188,
      "old_path": "src/main/java/com/google/devtools/build/lib/packages/semantics/FlagConstants.java",
      "new_id": "bdaa781eb95ca2d26c2ad21759de659d04b27c12",
      "new_mode": 33188,
      "new_path": "src/main/java/com/google/devtools/build/lib/packages/semantics/FlagConstants.java"
    },
    {
      "type": "modify",
      "old_id": "c65f77347287b69a8a5c33a9e7b871be04bdd9b6",
      "old_mode": 33188,
      "old_path": "src/main/java/com/google/devtools/build/lib/skyframe/BzlCompileFunction.java",
      "new_id": "184a5d4597e30f3545be689c78cc749fed042117",
      "new_mode": 33188,
      "new_path": "src/main/java/com/google/devtools/build/lib/skyframe/BzlCompileFunction.java"
    },
    {
      "type": "modify",
      "old_id": "cbe576dacd9d31408212accb599ac1700c90e6ac",
      "old_mode": 33188,
      "old_path": "src/main/java/net/starlark/java/eval/Eval.java",
      "new_id": "2a0fcaca1e09f5810e1bceb8e503cd4aeff8657d",
      "new_mode": 33188,
      "new_path": "src/main/java/net/starlark/java/eval/Eval.java"
    },
    {
      "type": "modify",
      "old_id": "0145e677569e6b4f2de1542adc807cbc8281eac4",
      "old_mode": 33188,
      "old_path": "src/main/java/net/starlark/java/syntax/AssignmentStatement.java",
      "new_id": "d0d00c2b8492451934d18d8f00797187af015376",
      "new_mode": 33188,
      "new_path": "src/main/java/net/starlark/java/syntax/AssignmentStatement.java"
    },
    {
      "type": "modify",
      "old_id": "9b13f786797fc5e50e87ff9ba4c1cff1e3ab9365",
      "old_mode": 33188,
      "old_path": "src/main/java/net/starlark/java/syntax/BUILD",
      "new_id": "1797511ea093d4cae58d527c577326fe826aceb5",
      "new_mode": 33188,
      "new_path": "src/main/java/net/starlark/java/syntax/BUILD"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "3b8732c659494643a3f5bf5865c5140fb58a404f",
      "new_mode": 33188,
      "new_path": "src/main/java/net/starlark/java/syntax/CastExpression.java"
    },
    {
      "type": "modify",
      "old_id": "884010dc223c24f41225e3bdb546ab227925897c",
      "old_mode": 33188,
      "old_path": "src/main/java/net/starlark/java/syntax/DefStatement.java",
      "new_id": "920e8b8fb92e6d9a231f15585b954b447b38875b",
      "new_mode": 33188,
      "new_path": "src/main/java/net/starlark/java/syntax/DefStatement.java"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "d20206a617496c937fa013722c906ab152b0cbb5",
      "new_mode": 33188,
      "new_path": "src/main/java/net/starlark/java/syntax/Ellipsis.java"
    },
    {
      "type": "modify",
      "old_id": "fa66a18e69d1b809182ae4221565ed59b54de840",
      "old_mode": 33188,
      "old_path": "src/main/java/net/starlark/java/syntax/Expression.java",
      "new_id": "92f6c8f041f905bf22f1331c0064511d3fb9b7c2",
      "new_mode": 33188,
      "new_path": "src/main/java/net/starlark/java/syntax/Expression.java"
    },
    {
      "type": "modify",
      "old_id": "a7111dc78a1a09c9d4d1f085a77db81ff0bafc23",
      "old_mode": 33188,
      "old_path": "src/main/java/net/starlark/java/syntax/FileOptions.java",
      "new_id": "b3106cb9dc2fbfef4e80a0c162a603cea250edf8",
      "new_mode": 33188,
      "new_path": "src/main/java/net/starlark/java/syntax/FileOptions.java"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "469f8892e6b8901eb77d72b633b63d005fd78553",
      "new_mode": 33188,
      "new_path": "src/main/java/net/starlark/java/syntax/IsInstanceExpression.java"
    },
    {
      "type": "modify",
      "old_id": "fcfa1d0eb1bc617c7ea7c7dfc5a9a070cd593489",
      "old_mode": 33188,
      "old_path": "src/main/java/net/starlark/java/syntax/Lexer.java",
      "new_id": "3d9e28e296773308706300322001ef6e83672ec5",
      "new_mode": 33188,
      "new_path": "src/main/java/net/starlark/java/syntax/Lexer.java"
    },
    {
      "type": "modify",
      "old_id": "16ca6e2c9a48a7f8d34a44b425f7febbb2b2d183",
      "old_mode": 33188,
      "old_path": "src/main/java/net/starlark/java/syntax/NodePrinter.java",
      "new_id": "f21a596daef57607ccb5e242a09a500b437f2b01",
      "new_mode": 33188,
      "new_path": "src/main/java/net/starlark/java/syntax/NodePrinter.java"
    },
    {
      "type": "modify",
      "old_id": "096f9506a46f8a2cf08b0bf375a255915e88ce20",
      "old_mode": 33188,
      "old_path": "src/main/java/net/starlark/java/syntax/NodeVisitor.java",
      "new_id": "d3998422664d5bbfd1e1795a450023ac9fab72cd",
      "new_mode": 33188,
      "new_path": "src/main/java/net/starlark/java/syntax/NodeVisitor.java"
    },
    {
      "type": "modify",
      "old_id": "8b7da9b1a42fa00441a74cf19c4dbf9a19686cbc",
      "old_mode": 33188,
      "old_path": "src/main/java/net/starlark/java/syntax/Parameter.java",
      "new_id": "836a469163f5ad91c1a9a3052e4d36430f636fb1",
      "new_mode": 33188,
      "new_path": "src/main/java/net/starlark/java/syntax/Parameter.java"
    },
    {
      "type": "modify",
      "old_id": "6f65fdc544d5a1fda0f3c462e8d17aed429277ab",
      "old_mode": 33188,
      "old_path": "src/main/java/net/starlark/java/syntax/Parser.java",
      "new_id": "5ddb304028d80d6115b92732b4e0c9c605e5d8c9",
      "new_mode": 33188,
      "new_path": "src/main/java/net/starlark/java/syntax/Parser.java"
    },
    {
      "type": "modify",
      "old_id": "a9fe1c02c5d1f9e097b8b1217940dd949e3c5e8d",
      "old_mode": 33188,
      "old_path": "src/main/java/net/starlark/java/syntax/Resolver.java",
      "new_id": "3495d9cfb44940460658ea9518719bf54e46310b",
      "new_mode": 33188,
      "new_path": "src/main/java/net/starlark/java/syntax/Resolver.java"
    },
    {
      "type": "modify",
      "old_id": "717abe69d6b0342c7d8f754635bfa6a68826ff28",
      "old_mode": 33188,
      "old_path": "src/main/java/net/starlark/java/syntax/Statement.java",
      "new_id": "860ed4c7a682b43290f7c625df0f7b2c08779ab9",
      "new_mode": 33188,
      "new_path": "src/main/java/net/starlark/java/syntax/Statement.java"
    },
    {
      "type": "modify",
      "old_id": "0b6ac6e6968462c11d6cd4dd37b958378b3bd4e5",
      "old_mode": 33188,
      "old_path": "src/main/java/net/starlark/java/syntax/TokenKind.java",
      "new_id": "dab4cc8ecda962bf7828280e8e1561d58f317576",
      "new_mode": 33188,
      "new_path": "src/main/java/net/starlark/java/syntax/TokenKind.java"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "f17e894156330310b4d3f27638fc5bb72afda939",
      "new_mode": 33188,
      "new_path": "src/main/java/net/starlark/java/syntax/TypeAliasStatement.java"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "4cbfa5fdafa3ecc3d90c5cc8584350b3f9efe06f",
      "new_mode": 33188,
      "new_path": "src/main/java/net/starlark/java/syntax/TypeApplication.java"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "5d65449729bb8b15fbf402315c3ca8a5f67660aa",
      "new_mode": 33188,
      "new_path": "src/main/java/net/starlark/java/syntax/VarStatement.java"
    },
    {
      "type": "modify",
      "old_id": "2ab8688213b3eb1b5d7f041a9ec58f7d874713cb",
      "old_mode": 33188,
      "old_path": "src/test/java/com/google/devtools/build/lib/packages/semantics/ConsistencyTest.java",
      "new_id": "7e7f8c19976f9cad8dff87a92d7d859da477ab0f",
      "new_mode": 33188,
      "new_path": "src/test/java/com/google/devtools/build/lib/packages/semantics/ConsistencyTest.java"
    },
    {
      "type": "modify",
      "old_id": "7db731208eeced168dbc7f046cfa0e41a0ecc09b",
      "old_mode": 33188,
      "old_path": "src/test/java/com/google/devtools/build/lib/starlark/BUILD",
      "new_id": "4af95045c8e9e767b596d0228b1f32fba46377be",
      "new_mode": 33188,
      "new_path": "src/test/java/com/google/devtools/build/lib/starlark/BUILD"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "f445c80520d30303e2200345347f886a4a05e2e3",
      "new_mode": 33188,
      "new_path": "src/test/java/com/google/devtools/build/lib/starlark/StarlarkTypesTest.java"
    },
    {
      "type": "modify",
      "old_id": "23446bd3e9319b51cf495c801bd0ddc1a3b9c094",
      "old_mode": 33188,
      "old_path": "src/test/java/net/starlark/java/eval/EvaluationTest.java",
      "new_id": "47c7dec647520596cdb47cd4fb2dadb2c7f5e835",
      "new_mode": 33188,
      "new_path": "src/test/java/net/starlark/java/eval/EvaluationTest.java"
    },
    {
      "type": "modify",
      "old_id": "272101b69510e74c1df88c257ac8025f36c240af",
      "old_mode": 33188,
      "old_path": "src/test/java/net/starlark/java/eval/EvaluationTestCase.java",
      "new_id": "e96d27117e25820e71082967ddec507ed8724f6b",
      "new_mode": 33188,
      "new_path": "src/test/java/net/starlark/java/eval/EvaluationTestCase.java"
    },
    {
      "type": "modify",
      "old_id": "cc7d468937d47ad95b747600d7fa53ab94152722",
      "old_mode": 33188,
      "old_path": "src/test/java/net/starlark/java/syntax/BUILD",
      "new_id": "c952f26118c2459f0ffdab17c89db49d9c5b9a96",
      "new_mode": 33188,
      "new_path": "src/test/java/net/starlark/java/syntax/BUILD"
    },
    {
      "type": "modify",
      "old_id": "1346919fd1475b7da15fb49ebf3927882fb3b230",
      "old_mode": 33188,
      "old_path": "src/test/java/net/starlark/java/syntax/LexerTest.java",
      "new_id": "e3e17901c19a0f0e921dc9dae9a9a46b0ef0f0c6",
      "new_mode": 33188,
      "new_path": "src/test/java/net/starlark/java/syntax/LexerTest.java"
    },
    {
      "type": "modify",
      "old_id": "ac3bae08a084d0771ca83b75fb574c54e02a2291",
      "old_mode": 33188,
      "old_path": "src/test/java/net/starlark/java/syntax/NodePrinterTest.java",
      "new_id": "da135ab249b2965c273e9a989667384f1fc3d9df",
      "new_mode": 33188,
      "new_path": "src/test/java/net/starlark/java/syntax/NodePrinterTest.java"
    },
    {
      "type": "modify",
      "old_id": "5abf79809d7dc477da864d672fee563db3c6dd30",
      "old_mode": 33188,
      "old_path": "src/test/java/net/starlark/java/syntax/ParserTest.java",
      "new_id": "7d849d5c5ed5533ad097fe30b886e7ec5cec7bd4",
      "new_mode": 33188,
      "new_path": "src/test/java/net/starlark/java/syntax/ParserTest.java"
    },
    {
      "type": "modify",
      "old_id": "847340c1c6af066ef09ca0c4204f5431bf9588a7",
      "old_mode": 33188,
      "old_path": "src/test/java/net/starlark/java/syntax/ResolverTest.java",
      "new_id": "378b9b06c97110f3b0b6928a683226dce3ffa4e9",
      "new_mode": 33188,
      "new_path": "src/test/java/net/starlark/java/syntax/ResolverTest.java"
    }
  ]
}
