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
Dartboard differs from Dart VM in treatment of if(1) { ... } #1190
Comments
This comment was originally written by ngeoffray@google.com Added Area-Compiler, Triaged labels. |
This comment was originally written by zundel@google.com The spec says that any non-boolean value must be converted to a boolean using boolean conversion. Here's the def'n: Boolean conversion maps any object o into a boolean defined as (bool v){ So it appears we need to change dartc code generation to add this logic to most conditional expressions, as even if type information is declared, at runtime a non-boolean type might be a part of an expression. |
This comment was originally written by molino....@gmail.com Also with 'checked mode' this example display the print statement: Code: |
var fullName; The correct behavior of the code above is:
|
This comment was originally written by gcod...@chqrlie.org What is the rationale for this dogmatic stance? Such a complete departure from commonly understood behaviour is so counter intuitive and error prone! Why not amend the boolean conversion semantics? |
This comment was originally written by zundel@google.com The issue about the language definition has been brought up in other places. Since dartc no longer generates code, I'm closing this bug as obsolete. Added WontFix label. |
Code:
main() {
if (1) {
print("I don't think this should work");
}
}
In Dartboard, with NON-checked mode, the print statement is displayed. A warning is displayed: int is not assignable to bool. In Checked mode, it errors as expected. Example: http://try.dartlang.org/s/SC0o
In Dart VM via the Dart Editor, the print statement is NOT displayed.
The text was updated successfully, but these errors were encountered: