Skip to content
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

Unexported (non-global) provider symbols are allowed despite documentation specification #23887

Open
jin opened this issue Oct 7, 2024 · 1 comment
Labels
team-Starlark-Integration Issues involving Bazel's integration with Starlark, excluding builtin symbols type: bug untriaged

Comments

@jin
Copy link
Member

jin commented Oct 7, 2024

Description of the bug:

https://bazel.build/rules/lib/globals/bzl#provider describes provider() to:

Defines a provider symbol. The result of this function must be stored in a global value. 

The use of "must" creates the expectation that such symbols would be disallowed, but there doesn't appear to be enforcement of this behavior.

Which category does this issue belong to?

No response

What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

$ cat defs.bzl
def _make_local_provider():
    return struct(inner = provider(fields = {"foo": ""}))

def impl(ctx): return None
r = rule(impl, attrs = {})

def m(name):
    print(_make_local_provider().inner(foo = "bar"))
    r(name = name)

$ cat BUILD
load(":defs.bzl", "m")
m(name = "t")

$ bazelisk build :t
DEBUG: .. unexported_providers/defs.bzl:8:10: struct(foo = "bar")
INFO: Analyzed target //:t (1 packages loaded, 1 target configured).
INFO: Found 1 target...
Target //:t up-to-date (nothing to build)
INFO: Elapsed time: 0.126s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action

$ bazelisk version
Bazelisk version: v1.10.1
Build label: 7.3.2
Build target: @@//src/main/java/com/google/devtools/build/lib/bazel:BazelServer
Build time: Tue Oct 1 17:46:05 2024 (1727804765)
Build timestamp: 1727804765
Build timestamp as int: 1727804765

The inner provider() was not stored in a global value, but the build still succeeded.

Which operating system are you running Bazel on?

linux

What is the output of bazel info release?

7.3.2

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

No response

What's the output of git remote get-url origin; git rev-parse HEAD ?

No response

If this is a regression, please try to identify the Bazel commit where the bug was introduced with bazelisk --bisect.

The documentation string was introduced in 3ebfe24

Have you found anything relevant by searching the web?

No response

Any other information, logs, or outputs that you want to share?

No response

@jin
Copy link
Member Author

jin commented Oct 7, 2024

cc @aoeui @michaeledgar

@satyanandak satyanandak added the team-Core Skyframe, bazel query, BEP, options parsing, bazelrc label Oct 7, 2024
@jin jin added team-Starlark-Integration Issues involving Bazel's integration with Starlark, excluding builtin symbols and removed team-Core Skyframe, bazel query, BEP, options parsing, bazelrc labels Oct 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-Starlark-Integration Issues involving Bazel's integration with Starlark, excluding builtin symbols type: bug untriaged
Projects
None yet
Development

No branches or pull requests

4 participants