Should inline lambdas be allowed as the test for an `if CompClause`
- Dominant language
- Java
- Stars
- 25.8k
- Forks
- 4.6k
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 72
Description
### Description of the bug:
The following syntax is allowed in Starlark:
```
[a for a in range(10) if lambda: True]
```
This is not allowed in Python. Should this syntax be allowed?
Maybe related context:
The following syntax is currently forbidden in both Starlark and Python
```
print(1 if lambda: True else 2)
```
and the following syntax is allowed in both Starlark and Python
```
print(1 if (lambda: True) else 2)
[a for a in range(10) if (lambda: True)]
```
### Which category does this issue belong to?
Starlark Interpreter
### What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
_No response_
### Which operating system are you running Bazel on?
_No response_
### What is the output of `bazel info release`?
_No response_
### 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.
_No response_
### Have you found anything relevant by searching the web?
_No response_
### Any other information, logs, or outputs that you want to share?
_No response_
Contributor guide
Research direction
No source files or tests are named. Start by examining the Starlark interpreter's handling of comprehension filters and compare it with the provided Python examples; done requires an agreed language-semantics decision and corresponding interpreter behavior or documentation.
Written by the indexing model from the issue text.
Assessment
- Domain
- build-system, compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100