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

dart2js warns expression yield void, while DartEditor doesn't #15812

Closed
DartBot opened this issue Dec 28, 2013 · 2 comments
Closed

dart2js warns expression yield void, while DartEditor doesn't #15812

DartBot opened this issue Dec 28, 2013 · 2 comments
Assignees
Labels
closed-obsolete Closed as the reported issue is no longer relevant type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) web-dart2js

Comments

@DartBot
Copy link

DartBot commented Dec 28, 2013

This issue was originally filed by @tomyeh


When compiling the following code, dart2js display a warning: Warning: Expression does not yield a value.

On the other hand, Dart Editor says nothing. No sure which is correct. Anyway, it is handy if allowed.

bool cond() => true;
void f1() {}
void f2() {}
void main() => cond() ? f1(): f2();

@lrhn
Copy link
Member

lrhn commented Jan 2, 2014

I'm not sure which is correct either. Let's deduce;

The static type of the conditional expression is the least upper bound of the types of the two expressions.
Both of these are void.
The least upper bound of void and any non-dynamic type is void.
So the least upper bound, and the type of the conditional expression, is void.

The form "=> e;" is equivalent to "{return e;}", so look at a "return e;" statement.

It is warning if the type of e (void) is may not be assigned to the declared type of the immediate enclosing function (void). That's not the case, so no warning from here.

Also, from the "Type Void" section:
"On the other hand, it is possible to return the result of a void method from within a void method."

It should be valid, so I'll mark this as a dart2js bug. Anything I'm missing, Johnni?


cc @johnniwinther.
Added Area-Dart2JS, Triaged labels.

@johnniwinther
Copy link
Member

It is a bug.


Set owner to @johnniwinther.

@kevmoo kevmoo added type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) and removed priority-unassigned labels Feb 29, 2016
@matanlurey matanlurey added the closed-obsolete Closed as the reported issue is no longer relevant label Jun 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-obsolete Closed as the reported issue is no longer relevant type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) web-dart2js
Projects
None yet
Development

No branches or pull requests

5 participants