"No Struct Literal" restriction should be applied to lambda function body #43412
Labels
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Currently
if || S {} {}
is parsed asif (|| S {}) {}
. I think it should be parsed asif (|| S) {} {}
, to be consistent with handling of other similar "open" binary and prefix expressions (lambdas can be viewed as a form of a prefix expression).Consider these expressions:
They are parsed as
ast json
The last two cases seem to be different from others and wrong. @eddyb on IRC suggested that this behavior could have been introduced accidentally during transition from lambdas with blocks as bodies to lambdas with arbitrary expressions as bodies.
If this is a bug, fixing it can render some previously valid programs invalid, but this seems rater unlikely, as bare lambdas rarely end up in conditionals. It is possible though:
The text was updated successfully, but these errors were encountered: