-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
select() is not resolved when used in a list comprehension or dict.values() #8171
Comments
I think it's working as intended. The select object supports the However, if you do This may help understand what happens: |
Ahhh, so what I'm really seeing with the Are the In the meantime, is there a recommended cleaner way to implement the behaviour I'm looking for? I can use a macro function, but it's a bit clunky. |
Yes. Any attribute's value setting can ultimately be an arbitrary concatenation of native values and
will always fully resolve. Anything that's not that exact pattern, which would include explicitly converting the
What exact behavior are you looking for? It seems that listifying or stringifying a |
No. Future behavior (you can try it with |
EDIT: something is up with github's comment ordering, the posts I'm responding to have a modification time in the future.
Correct, the listifying/stringifying is a workaround to expand the The use case is that we want to be able to have a set of values set in one place with a In particular, I encountered this behaviour when trying to write a
I guess this issue has morphed into a request for a nicer way to do things like list comprehensions using |
I appreciate your point - these are awfully similar UIs and intuitively it's frustrating that what should be basically a small cosmetic difference has such divergent implications. Unfortunately I don't think there's an obvious fix. The core challenge, which is decidedly not obvious just casually looking at the syntax as a user, is that while BUILD evaluation looks a lot like pure Python execution, it's actually a two-phased process. Pure Pythonic expressions like comprehensions are evaluated in the first phase. But It's actually possible to construct a build with two targets such that the same Straight-up Every new Pythonic expression we'd want to support This is all theoretically possible. But it's not simple, and in the end I think comes down to arbitrary interleaving of these two evaluation phases, which would require some pretty deep Bazel design changes. I realize these difficulties are subtle and non-obvious. I still appreciate what you're trying to do and would be happy to consider possibly more limited solutions that don't hit these challenges straight-on. |
Understood. Thanks for the thorough explanation of what's going on, the insight is very helpful and greatly appreciated! A low-effort-high-impact improvement might be a section in the |
Marking this is a documentation issue due to the last comment. |
I'm decisively moving I think the right followup is for the team focusing on docs improvement to group together As always anyone is welcome to off their own ad hoc PR. |
Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 1+ years. It will be closed in the next 90 days unless any other activity occurs. If you think this issue is still relevant and should stay open, please post any comment here and the issue will no longer be marked as stale. |
This issue has been automatically closed due to inactivity. If you're still interested in pursuing this, please post |
Description of the problem / feature request:
If a dictionary or list contains a
select()
, and that dict/list is used in a list comprehension (i.e. when constructing a string of all keys in the dict), theselect()
is not resolved.The
select()
is also not resolved when accessing the values in a dict usingdict.values()
.Using a
for
loop to construct a string in a macro instead of a list comprehension expands theselect()
as expected. However, constructing a list in a macro does not expand theselect()
.Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
test.bzl
:BUILD.bazel
:What operating system are you running Bazel on?
Ubuntu 18.04
What's the output of
bazel info release
?release 0.22.0
The text was updated successfully, but these errors were encountered: