From def68f5a15cfa68c0b281cdb2376dfd2350fcb61 Mon Sep 17 00:00:00 2001 From: Ralf Anton Beier Date: Wed, 20 May 2026 19:00:14 +0200 Subject: [PATCH] fix: use ctx.toolchains[] subscript instead of nonexistent .get() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ToolchainContext has no .get() method — toolchain access is via subscript. Two call sites used ctx.toolchains.get(...), which fails at analysis with "'ToolchainContext' value has no field or method 'get'": - common/wasm_component_utils.bzl: validate_component_action(), hit whenever a component rule sets validate_wit = True - wit/private/wit_bindgen.bzl: the Go binding-generation path Both now use the ctx.toolchains[...] subscript form, matching the already- correct usage 6 lines below in wit_bindgen.bzl. Introduced in 6bbd9873 (2026-03-22). Validated: the previously analysis-failing //examples/multi_profile and //examples/world_export targets now pass analysis. (They still fail later on a separate, pre-existing wit-bindgen world-name mismatch — unrelated to this fix.) Co-Authored-By: Claude Opus 4.7 (1M context) --- common/wasm_component_utils.bzl | 2 +- wit/private/wit_bindgen.bzl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/common/wasm_component_utils.bzl b/common/wasm_component_utils.bzl index 0bbc1169..05dd1267 100644 --- a/common/wasm_component_utils.bzl +++ b/common/wasm_component_utils.bzl @@ -179,7 +179,7 @@ def validate_component_action(ctx, wasm_file, wit_file = None): if not (hasattr(ctx.attr, "validate_wit") and ctx.attr.validate_wit): return [] - wasm_toolchain = ctx.toolchains.get("@rules_wasm_component//toolchains:wasm_tools_toolchain_type") + wasm_toolchain = ctx.toolchains["@rules_wasm_component//toolchains:wasm_tools_toolchain_type"] if not wasm_toolchain: return [] diff --git a/wit/private/wit_bindgen.bzl b/wit/private/wit_bindgen.bzl index 6d3dfc07..eb7b25f5 100644 --- a/wit/private/wit_bindgen.bzl +++ b/wit/private/wit_bindgen.bzl @@ -75,7 +75,7 @@ def _wit_bindgen_impl(ctx): # Get wit-bindgen tool from appropriate toolchain if ctx.attr.language == "go": # Check if TinyGo toolchain is available - tinygo_toolchain = ctx.toolchains.get("@rules_wasm_component//toolchains:tinygo_toolchain_type") + tinygo_toolchain = ctx.toolchains["@rules_wasm_component//toolchains:tinygo_toolchain_type"] if not tinygo_toolchain: fail("TinyGo toolchain not available. Go WIT binding generation requires TinyGo toolchain.") wit_bindgen = tinygo_toolchain.wit_bindgen_go