-
Notifications
You must be signed in to change notification settings - Fork 26
Downward inference into closures doesn't handle returns #308
Comments
@vsmenon -- is this because we have better inference for arrow functions, compared with |
Yeah, here: https://github.com/dart-lang/dev_compiler/blob/master/lib/src/checker/rules.dart#L790 We'd need to handle |
Yes. I do downwards inference on functions, which is what allows your "bar" example to pass. If I'm inferring a function in a context expecting a |
I'm working on getting an old project of mine error-free in strong mode and I hit this case pretty frequently. I would really like full return type inference for block-bodied lambdas and local function declarations. (I don't expect it for top-level fns because of recursion.) I think this may be the most common source of strong mode warnings in that codebase. |
Yeah, thanks for the ping Bob. I personally haven't enabled strong_mode for DDC yet either(!). The three big blockers are this bug, lambda parameter inference (e.g. this affects the very common |
Fixed in https://codereview.chromium.org/1462133005/ . |
🎆 |
In the following, we get a strong more error on
foo
, but not onbar
:The following also doesn't trigger a warning:
which feels inconsistent.
@leafpetersen Is this ultimately an ordering issue? It feels like we want to push down the param type before type checking the body.
@nex3 is hitting this when running strong mode on shelf.
The text was updated successfully, but these errors were encountered: